mvc how to change default route

后端 未结 3 507
伪装坚强ぢ
伪装坚强ぢ 2021-01-16 14:06

I\'m going through the Pro Asp.net mvc3 framework book. I wanting to change the default route so that I can have a different home page. I\'ve added a new controller called P

3条回答
  •  感动是毒
    2021-01-16 14:51

    Be sure to place the default route at the very end of the route mappings. If it's last there's no way it can screw up the categories route.

    Update If this route:

    routes.MapRoute(null, "{controller}/{action}");
    

    comes before the default, it will catch anything that you would expect your default route to catch except items with a third URL parameter (id).

    So for example:

    /somepage/home
    

    would get caught by this above route, rather than your default.

    So you probably want to delete this route.

提交回复
热议问题