2017-01-02 3 views
0

Ich habe ein Problem in meinem ASP.NET MVC-Projekt Ich habe 3 Bereich, aber in 1 ist in Ordnung. In anderen 2 Bereichen habe ich ein Problem mit Abfrage-String aus dem Browser. Globale RouteWo finde ich meine Web-Anfrage in 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); 
    } 
} 

In meinem Benutzerbereich ist diese Route:

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

Haben Sie in der Registrierung Bereiche gesucht. Siehe diese stackoverflow-Antwort: http://stackoverflow.com/questions/13454699/how-to-register-areas-for-routing –

+0

Vielleicht suchen Sie [RouteContraints] (http://stackoverflow.com/questions/4269046/) can-my-mvc2-app-spezifiziere-route-constraints-on-query-string-parameter)? –

Antwort

0

Anruf AreaRegistration.RegisterAllAreas() in der RegisterRoutes:

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