2017-01-02 75 views
0

我在我的ASP.NET MVC項目有問題 我有3個區域,但在1是好的。 在其他2個領域,我從瀏覽器查詢字符串有問題。 全球航線我在哪裏可以找到我的web請求在ASP.NET MVC

public class RouteConfig 
{ 
    public static void RegisterRoutes(RouteCollection routes) 
    { 
     routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
     routes.MapRoute(
      name: "Default", 
      url: "{controller}/{action}/{id}", 
      defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 
     ); 
    } 

    protected void Application_Start() 
    { 
     RegisterRoutes(RouteTable.Routes); 
    } 
} 

在我的用戶區是這條路線:

public class UserAreaRegistration : AreaRegistration 
{ 
    public override string AreaName 
    { 
     get 
     { 
      return "User"; 
     } 
    } 

    public override void RegisterArea(AreaRegistrationContext context) 
    { 
     context.MapRoute(
      "User_default", 
      "user/{controller}/{action}/{id}", 
      new { action = "Index", id = UrlParameter.Optional } 
     ); 
    } 
} 
+0

你有沒有看着註冊的地區。看到這個stackoverflow答案:http://stackoverflow.com/questions/13454699/how-to-register-areas-for-routing –

+0

也許你正在尋找[RouteContraints](http://stackoverflow.com/questions/4269046/可以-MY-MVC2-APP-指定路由約束上查詢字符串參數)? –

回答

0

呼叫AreaRegistration.RegisterAllAreas()在你的RegisterRoutes:

public static void RegisterRoutes(RouteCollection routes) 
{ 
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 
    AreaRegistration.RegisterAllAreas(); 
    .... 
} 
相關問題