Asp.net-Mvc
未找到視圖“索引”或其主視圖。
The view 'Index' or its master was not found. The following locations were searched: ~/Views/ControllerName/Index.aspx ~/Views/ControllerName/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx使用 ASP.Net mvc 區域時出現此錯誤。區域控制器操作被呼叫,但它似乎在“基礎”項目視圖中而不是在區域視圖文件夾中查找視圖。
問題是我使用
MvcRoute.MappUrlfromMvcContrib來路由context.Routes.路由映射器似乎對
MvcContrib區域路由感到不舒服。
您需要做的是為您的區域名稱設置一個令牌:
例如:
context.MapRoute( "SomeArea_default", "SomeArea/{controller}/{action}/{id}", new { controller = "SomeController", action = "Index", id = UrlParameter.Optional } ).DataTokens.Add("area", "YOURAREANAME");