Asp.net MVC 4新项目中创建area的后续操作
生活随笔
收集整理的這篇文章主要介紹了
Asp.net MVC 4新项目中创建area的后续操作
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Asp.net MVC 4新項(xiàng)目中創(chuàng)建area后,往往HomeController與area的HomeController路由發(fā)生混淆,需要手工設(shè)置一些地方避免mvc無(wú)法識(shí)別默認(rèn)路由的狀況。
無(wú)廢話具體步驟:
1. 檢查早Global.asax和\App_Start\RouteConfig.cs中是否已經(jīng)自動(dòng)添加了AreaRegistration.RegisterAllAreas();如不存在,進(jìn)入第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()中是否顯性指定了默認(rèn)Controller的namespace。
namespaces: new[] { "TestMvcApplication.Controllers" }?
轉(zhuǎn)載于:https://www.cnblogs.com/heuyang/p/5024986.html
總結(jié)
以上是生活随笔為你收集整理的Asp.net MVC 4新项目中创建area的后续操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 陈卓璇浙江卫视2023#美好中国新歌会#
- 下一篇: 家用投影机选哪个牌子好?