视图“索引”或者找不到它的主人
今天我开始使用区域重组我的 mvc 项目。所以我有一些问题。 我创建区域,移动视图和母版页,进行路由,但是当我尝试查看任何区域页面时,我得到“无法找到视图“登录”或其母版页。”
有什么建议吗?我用谷歌搜索了一段时间,但没有找到任何解决方案。
我的global.asax路由:
routes.MapRoute("Areaname", "Areaname",
"Areaname/{controller}/{action}/{id}",
new { controller = "controllerName", action = "Home", id = UrlParameter.Optional },
new string[] { "path.to.area.controllers.Controllers" });
区域注册路由:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Areaname_default",
"Areaname/{controller}/{action}/{id}",
new { action = "Home", id = UrlParameter.Optional },
new string[] { "path.to.area.controllers.Controllers" }
);
}
看起来是正确的,但是视图仍然不可用。
提前致谢。
Today I've started restructuring my mvc project using areas. So I have some problems with it.
I make areas, move views and master pages, make routing, but when I'm trying to view any area page I get "The view 'Login' or its master could not be found."
Any suggestions? I've googled for some time, but didn't found any solution.
My global.asax routing:
routes.MapRoute("Areaname", "Areaname",
"Areaname/{controller}/{action}/{id}",
new { controller = "controllerName", action = "Home", id = UrlParameter.Optional },
new string[] { "path.to.area.controllers.Controllers" });
Area registration routing:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Areaname_default",
"Areaname/{controller}/{action}/{id}",
new { action = "Home", id = UrlParameter.Optional },
new string[] { "path.to.area.controllers.Controllers" }
);
}
It seems to be correct, but views are still unavailable.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用区域时,请确保像这样重写操作链接:
在本例中,您链接到“CustomerInvoices”控制器内“Invoicing”区域内的“Index”操作。
确保您进行适当的修改以链接到您区域内的登录操作!
When using Areas, make sure you rewrite your action links like this:
In this example, you are linking to the "Index" action, inside "CustomerInvoices" controller, inside "Invoicing" Area.
Make sure you do the proper modifications to link to the Login action inside your Area!