asp.net mvc 区域默认页面
我有一个带有区域的 MVC 2 站点,假设区域名称是 {Admin}
区域和站点工作正常。
我想做的是为该区域设置不同的默认页面。
当我打电话时 http://webSiteName 没有问题,
但对于 http://webSiteName/Admin 我收到错误
找不到资源
我尝试了 当未指定区域时,ASP.NET MVC 2 RC 2 返回特定于区域的控制器 但没有运气。
我也尝试过
routes.MapRoute(
"Admin",
"{controller}/{action}/{id}",
new { controller = "AdminHome", action = "index" },
new[] { "Web.Areas.Admin.Controllers" }
);
,
routes.MapRoute(
"Admin",
"Admin",
new { controller = "AdminHome", action = "index" },
new string[] { "Web.Areas.Admin.Controllers" }
);
但仍然出现找不到资源。
我做错了什么?
I have a MVC 2 site with an area, let's say the area name is {Admin}
The areas and the site works fine.
What I am trying to do is to have different default page for the area.
When I am calling http://webSiteName works with no problem
but for http://webSiteName/Admin I am getting the error
The resource cannot be found
I tried it out the solutions from ASP.NET MVC 2 RC 2 returns Area-specific controller when no area specified
but with no luck.
I tried also
routes.MapRoute(
"Admin",
"{controller}/{action}/{id}",
new { controller = "AdminHome", action = "index" },
new[] { "Web.Areas.Admin.Controllers" }
);
and
routes.MapRoute(
"Admin",
"Admin",
new { controller = "AdminHome", action = "index" },
new string[] { "Web.Areas.Admin.Controllers" }
);
but I am still getting The resource cannot be found.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个。当您的区域名为
Admin
时,请确保它位于/Areas/Admin/AdminAreaRegistration.cs
中。您不必向
Global.asax
添加任何内容。Try this. Make sure it will be in
/Areas/Admin/AdminAreaRegistration.cs
when your Area is namedAdmin
.You don't have to add anything to your
Global.asax
.