Asp.Net MVC5 Project Admin Area Route - Error Routing Contro
本文关键字:Error Routing Contro Route Area Net MVC5 Project Admin Asp | 更新日期: 2023-09-27 18:08:38
MVC5项目我为管理面板创建了区域。我遇到一个问题。
有ProductController和ListActionResult在前面的站点。
.
有ProductController和ListActionResult在管理面板。
现在…
我要去管理面板ProductController和ListActionResult.(www.xxxxxxxxx.com/Admin/Home/List)
但是项目在首页打开。 (www.xxxxxxxxx.com/Home/List)
我要打开的页面>> www.xxxxxxxxx.com/Admin/Home/List
但是这个打开的页面>> www.xxxxxxxxx.com/Home/List
不改变页面地址
但它是控制器。
有什么问题
以下是路由信息。
AdminAreaRegistration.cs;
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context )
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", controller = "Home", id = UrlParameter.Optional },
new[] { "Projem.Web.Areas.Admin.Controllers" }
;
}
RouteConfig.cs;
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes )
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}" );
routes.MapMvcAttributeRoutes( );
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "Projem.Web.Controllers" }
;
}
}
像这样更改RegisterArea方法。
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", area = "Admin", id = "" },
new[] { "Projem.Web.Areas.Admin.Controllers" }
);
}