Thursday, September 8, 2016

Routing to a default Area in ASP.NET MVC

When you take a look at RouteConfig.cs in an ASP.NET MVC Web Application, you will notice that you cannot set a default Area when you initially load the application.

Instead, ASP.NET MVC will usually default to the Index action of the Home Controller in the root directory by default!

So how do you work around this limitation?

Well, there are numerous solutions to doing this by altering and modifying the default behavior or RouteConfig.cs, but I feel the simplest solution is best.

Simply go into the Index action of the Home controller and add a Redirect similar to the following:

No comments:

Post a Comment