0

I have problem in my ASP.NET MVC project I have 3 area, but in 1 is ok. In other 2 areas i have problem with query string from browser. Global route

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 my user area is this 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 }
        );
    }
}
Daniel
  • 9,491
  • 12
  • 50
  • 66
xeso
  • 61
  • 1
  • 6
  • Have you looked into registering Areas. See this stackoverflow answer: http://stackoverflow.com/questions/13454699/how-to-register-areas-for-routing – Saqib Rokadia Jan 02 '17 at 21:53
  • Maybe you are looking for [RouteContraints](http://stackoverflow.com/questions/4269046/can-my-mvc2-app-specify-route-constraints-on-query-string-parameters)? – Christian Gollhardt Jan 02 '17 at 22:55

1 Answers1

0

Call AreaRegistration.RegisterAllAreas() in your RegisterRoutes:

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    AreaRegistration.RegisterAllAreas();
    ....
}
Ankit Sahrawat
  • 1,306
  • 1
  • 11
  • 24