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 区域时遇到此错误。区域 Controller 操作被调用,但它似乎在“基本”项目 View 中查找 View ,而不是在区域 View 文件夹中。
最佳答案
您需要做的是为您的区域名称设置一个 token :
例如:
context.MapRoute(
"SomeArea_default",
"SomeArea/{controller}/{action}/{id}",
new { controller = "SomeController", action = "Index", id = UrlParameter.Optional }
).DataTokens.Add("area", "YOURAREANAME");
关于asp.net-mvc - 未找到 View 'Index' 或其主视图。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2269220/