Search code examples
c#asp.net-mvcasp.net-mvc-5asp.net-mvc-routingasp.net-mvc-areas

Default area route not working in mvc 5


I added the default controller and action name but still the default routing is not working for the area. Here is my code:

AreaRegistration.cs

public override void RegisterArea(AreaRegistrationContext context) 
{
    context.MapRoute(
        "Admin_default",
        "Admin/{controller}/{action}/{id}",
        new { controller ="LogIn", action = "Index", id = UrlParameter.Optional }
    );
}

RouteConfig.asax

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

When i go to http://webapplocal/admin/ i get the below error: 403 forbidden: A default document is not configured for the requested URL, and directory browsing is not enabled on the server.


Solution

  • I added RouteTable.Routes.RouteExistingFiles = true; in RouteConfig.cs and it worked