0

我正在研究 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}
            );

但是没有用,它们都对我不起作用,这意味着它显示资源未找到错误。请指导我。

4

1 回答 1

0

尝试安装Route Debugger nuget 包,它可以帮助您了解为什么事情不匹配

于 2012-10-25T09:14:06.423 回答