且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 asp.net MVC 4 & 中设置默认控制器MVC 5

更新时间:2023-10-07 11:48:52

***的方法是改变你的路线.默认路由(在你的 App_Start 中定义)设置 /Home/Index

the best way is to change your route. The default route (defined in your App_Start) sets /Home/Index

routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters*
        new { controller = "Home", action = "Index", 
        id = UrlParameter.Optional }
);

作为默认登陆页面.您可以将其更改为您希望的任何路线.

as the default landing page. You can change that to be any route you wish.

routes.MapRoute(
        "Default", // Route name
        "{controller}/{action}/{id}", // URL with parameters*
        new { controller = "Sales", action = "ProjectionReport", 
        id = UrlParameter.Optional }
);