Asp.net MVC 4新项目中创建area的后续操作
生活随笔
收集整理的这篇文章主要介绍了
Asp.net MVC 4新项目中创建area的后续操作
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
Asp.net MVC 4新项目中创建area后,往往HomeController与area的HomeController路由发生混淆,需要手工设置一些地方避免mvc无法识别默认路由的状况。
无废话具体步骤:
1. 检查早Global.asax和\App_Start\RouteConfig.cs中是否已经自动添加了AreaRegistration.RegisterAllAreas();如不存在,进入第2步,否则第3步
2. 在\App_Start\RouteConfig.cs中,添加AreaRegistration.RegisterAllAreas();
public static void RegisterRoutes(RouteCollection routes) {routes.IgnoreRoute("{resource}.axd/{*pathInfo}");AreaRegistration.RegisterAllAreas();routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },namespaces: new[] { "TestMvcApplication.Controllers" }); }3. 在\App_Start\RouteConfig.cs中,检查routes.MapRoute()中是否显性指定了默认Controller的namespace。
namespaces: new[] { "TestMvcApplication.Controllers" }
转载于:https://www.cnblogs.com/heuyang/p/5024986.html
总结
以上是生活随笔为你收集整理的Asp.net MVC 4新项目中创建area的后续操作的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 陈卓璇浙江卫视2023#美好中国新歌会#
- 下一篇: KVC和KVO