A colleague deploys an ASP. NET MVC site, wants its default page to be index.html page, adds index.html to the site root in vs2010, and then calls no problem, but deploys to IIS7, in function attempt = " The default document added Index.html, but only the domain name or not access, it seems that the reasons for. NET MVC and IIS incompatibility, and later colleagues adopted the method is to write the default page in the global file to log in a page, so because there is no permissions, The system will automatically jump to the login page
public static void RegisterRoutes (RouteCollection routes)
{
Routes. Ignoreroute ("{resource}.axd/{*pathinfo}");
Routes. MapRoute (
"Default",//route name
' {controller}/{action}/{id} ',//URL with parameter
New {controller = "indexpage", action = "Index", id = urlparameter.optional}//parameter default value
);
}
Friends found a good blog, feel more flexible implementation methods, as follows:
Method 1:
In the Global.asax file, add
protected void Application_BeginRequest (object sender, EventArgs e)
{
if (Context.Request.FilePath = = "/") Context.rewritepath ("index.html");
}
Method 2:
Create a new route Defaultcontroller, set it as the default route, and increase it in action
Redirect (Url.content ("~/index.html"));
This method needs to modify the Web. config configuration
Add in the <compilation> node in the Web. config file:
<buildProviders>
<add extension= ". htm" Type= "System.Web.Compilation.
Set the ASP. NET MVC site default page to an. html page.