asp.net MVC3 site to set the HTML default home page method

Source: Internet
Author: User

The reason is that my asp.net MVC3 project does not have a home page, and the default document index.asp the IIS settings does not take effect.

asp.net MVC3 website Settings first page is HTML or ASP file

Open Global.asax, add the following code to resolve:

The code is as follows Copy Code

protected void Application_BeginRequest (object sender, EventArgs e)
{
if (Context.Request.FilePath = = "/") Context.rewritepath ("index.asp");
}

Later on the internet also found a number of ways to share the following two a good

Creates a new routing Defaultcontroller and sets it as the default route, increasing in action
Redirect (Url.content ("~/index.html"));
This method needs to modify the Web.config configuration
Increase in the <compilation> node in the Web.config file:

  code is as follows copy code

< Buildproviders>
  <add extension= ". htm" type= "System.Web.Compilation.PageBuildProvider"/>
</buildproviders>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.