I have this routes:
我有这条路线:
My website route on WebSite/Global.asax.cs
:
我在WebSite / Global.asax.cs上的网站路线:
namespace WebSite
{
public class MvcApplication : HttpApplication
{
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
...
routes.MapRoute(
"Default",
"Authenticated/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "WebSite.Controllers" }
);
...
}
void Application_Start()
{
...
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
...
}
}
}
My Admin Area route on WebSite/Areas/Admin/AdminAreaRegistration.cs
:
我在WebSite / Areas / Admin / AdminAreaRegistration.cs上的管理区路由:
namespace WebSite.Areas.Admin
{
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"qwerty/Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new[] { "WebSite.Areas.Admin.Controllers" }
);
}
}
}
My URLs:
WebSite: http://www.mywebsite.com/Authenticated/Controller/Action...
Admin: http://www.mywebsite.com/qwerty/Admin/Controller/Action...
My problem:
With WebSite URL I can call Controllers/Actions from Admin Area, without use "qwerty/Admin", and this is not right. How can I fix this?
使用WebSite URL,我可以从管理区域调用控制器/操作,而不使用“qwerty / Admin”,这是不对的。我怎样才能解决这个问题?
Thank you.
1 个解决方案
#1
3
Just put this code after each MapRoute. It should work!
只需在每个MapRoute之后输入此代码即可。它应该工作!
.DataTokens["UseNamespaceFallback"] = false;
#1
3
Just put this code after each MapRoute. It should work!
只需在每个MapRoute之后输入此代码即可。它应该工作!
.DataTokens["UseNamespaceFallback"] = false;