I have an ASP.NET MVC application where the default page should be index.html which is an actual file on disk.
I can browse to the file using www.mydomain.com/index.
I found a way around this. If you want index.html to be in the root of your MVC application (i.e next to your controller/model/view/appdata etc folders), you can do this:
Say you have home.html, aboutus.html and contactus.html.
//this route matches (http://mydomain.com/somekindofstring)
routes.MapRoute(
"SingleRootArg",
"{id}",
new { controller = "Home", action = "Details", id=""});
// so now that you have your route for all those random strings.
// I had to do this for vanity urls. mydomain.com/ronburgandy etc. however,
// mydomain.com/index.html will also come in just how you'd expect.
//Just an example of what you COULD do. the user would see it as root html.
Public ActionResult Details(string id)
{
//let me save you the trouble - favicon really comes in as a string *ANGER*
if(String.IsNullOrEmpty(id) || id.ToLower().Contains("favicon.ico"))
return Redirect("~/index.html");
if(id == "aboutus.html")
return Redirect("~/aboutus.html");
if(id == "contactus.html")
return Redirect("~/contactus.html");
if(id == "index.html")
return Redirect("~/index.html");
}
index.html aboutus.html index.html are now at the same level as my CSPROJ file.