我正在研究 asp.net mvc 3。我正在尝试用区域实现该项目。我面临路由问题。我有类似的文件夹结构,projectName/areas/Dashboard/
并且在我的 DashboardAreaRegistration.cs
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Default_Dashboard",
"Dashboard/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
所以我的路由看起来像,localhost:56788/Dashboard/Dashboard/Index
在这里我需要我的路由应该看起来像localhost:56788/Dashboard/Index
我写的那样,
context.MapRoute(
"Default_Dashboard",
"Dashboard/{action}/{id}",
new { area = "Dashboard", controller = "Dashboard", action = "PatientPortal", id = UrlParameter.Optional },
new[]{typeof(Controllers.DashboardController).Namespace}
);
context.MapRoute(
"Default_Dashboard",
"{controller}/{action}/{id}",
new { area = "Dashboard", controller = "Dashboard", action = "PatientPortal", id = UrlParameter.Optional },
new[]{typeof(Controllers.DashboardController).Namespace}
);
但是没有用,它们都对我不起作用,这意味着它显示资源未找到错误。请指导我。