1

I am trying to set the default route for ~/ to the Area OnlineUser:

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", 
                            area="OnlineUser", id = UrlParameter.Optional }
        );
    }

However it errors out indicating that going to the root "/" of the site is an exception because ti can't find a controller/action.

Am I setting the Area wrong?

I have a Home and Index in the Area and can get to the Area nicely via its route:

        context.MapRoute(
            "OnlineUser_default",
            "OnlineUser/{controller}/{action}/{id}",
            new { action = "Index", id = UrlParameter.Optional }
        );

The Exact error is:

The view 'Index' or its master was not found or no view engine supports the 
searched locations. The following locations were searched: 
~/Views/Home/Index.aspx ~/Views/Home/Index.ascx 
~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx 
~/Views/Home/Index.cshtml ~/Views/Home/Index.vbhtml 
~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml
Ian Vink
  • 60,720
  • 99
  • 311
  • 535

0 Answers0