Asp.net 区域路由被忽略?

Asp.net 区域路由被忽略?,asp.net,asp.net-mvc-3,routes,Asp.net,Asp.net Mvc 3,Routes,我有以下路线: routes.MapRoute( "Advertisers", "advertisers/{controller}/{action}/{id}", new { controller = "Index", action = "Index", id = UrlParameter.Optional }, new string[] { "Portal.Areas.Advertisers.Controllers" } ); routes.MapRoute(

我有以下路线:

routes.MapRoute(
    "Advertisers",
    "advertisers/{controller}/{action}/{id}",
    new { controller = "Index", action = "Index", id = UrlParameter.Optional },
    new string[] { "Portal.Areas.Advertisers.Controllers" }
);

routes.MapRoute(
    "Root", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Index", action = "Index", id = UrlParameter.Optional }, // Parameter defaultsm
    new string[] { "Portal.Controllers" }
);
但是,每当我转到/advisors/controller/action/id时,它都不会读取id参数。。。我做错了什么


谢谢

我建议你看一下

nuget安装

PM>安装程序包RoutedBugger

将其安装到项目中后,将这一行代码放入应用程序启动方法中,然后点击正在调试的url

protected void Application_Start()
{
    RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
这将确切地告诉您为什么您的路线没有按预期工作

至于您的实际问题,您的
控制器
是否实际被称为
IndexController
?因为我觉得这不对

public class IndexController : Controller
{

    public ActionResult Index()
    {
        return View();
    }

}
我的假设是,您实际上拥有类似于
HomeController
AdvertiserController
的东西,如果是这种情况,您应该拥有类似的东西

routes.MapRoute(
    "advertisers_default", // Route name
    "advertisers/{controller}/{action}/{id}/{advertiserName}", // URL with parameters
    new { controller = "Home", 
          action = "Index", 
          advertiserName = UrlParameter.Optional },
    new { id = "[0-9]+",
          controller = "[a-zA-Z]+",
          action = "[a-zA-Z]+" }
);
然后点击url{id}/{广告商名称}

简单地说,这个url在我看来是错误的

/广告商/控制器/操作/{id}

应该是
/advisors/home/{id}

甚至
/advisors/home/{id}/{advister name}


谢谢,调试器很好,它似乎允许我做我需要做的事情。没问题。它无疑是MVC路线构建的最佳工具之一。