I have an MVC 3 solution that is broken down into areas. I can access the application in the following ways for example: //myapp/ or //myapp/external or //myapp/internal. What I am trying to accomplish in IIS 7 is to set the default URL (in my case would be //myapp) to //myapp/internal.
So anytime someone navigates to //myapp they are redirected to //maypp/internal (internal is the name of the area I have set up in MVC).
I am really looking for a way to do this on the server and not in global.asax. The reason being is because this app will be on multiple servers and I don't want to have to change the default route every time I need to deploy my app.
Thanks for the help.
I ended up solving my issue the following way:
a. In my Web.Internal.config file I added this transformation:
<appSettings>
<add key="Environment" value="Production Internal(Live)" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
Now when I deploy my solution to my internal site the Environment value in my Web.config is overwritten with "Production Internal(Live)"
b. I then added a check in my default controller and action to lookup the Environment value in the Web.config
var InternalorExternalSite = Convert.ToString(ConfigurationManager.AppSettings["Environment"]);
if (InternalorExternalSite == "Production Internal(Live)")
{
return RedirectToAction("", "", new { area = "Internal" });
}
The above code will check if the Environment value is equal to "Production Internal(Live)" in my case and redirect the request to the Area "Internal".
Now when an internal user navigates to http://www.internalsite.com they are redirected to the Area http://www.internalsite.com/internal
When an external user navigates to http://www.externalsite.com they are not redirected to any area, but if you needed to you could redirect the user to any area based on the above.