简体   繁体   中英

Is there a way in Visual Studio to configure the default start page for web deployment starting from Empty ASP.NET Web App?

Entry level web developer here, thank you in advance.

A very basic single page website starting from Empty ASP.NET Web Application adding each and folder file from scratch. Everything works fine locally bare bones. I'm trying to configure the start page in the subfolder "html" to the file index.html. I get the default "This website has been successfully created" after publishing. Azure web service is working fine because I can go to site.azurewebsites.net/html/index.html to see my page after it's published.

Right clicking the project and going to properties to set as start page, or going to Properties>Specific Page doesn't work as suggested here for deployment but works fine locally. Altering the web.config file as suggested here gives me an internal server error that is fixed once I remove the code

<system.webServer>
   <defaultDocument enabled="true">
    <files>
     <clear />
    <add value="html/index.html"/>
   </files>
  </defaultDocument>
</system.webServer>

I tried different variations of this all with the same internal server error. Is my syntax correct?

I then created a global.asax file and changed the Application_Start line as suggested here :

protected void Application_Start(object sender, EventArgs e)
{
   Response.Redirect("/HTML/index.html");
}

Same result.

Lastly, I created an App_Code folder with a RedirectHandler.cs file as suggested by Rion Williams's last suggestion (first link) along with his code and sure enough I get the same result. "This web app has been successfully created" after publish but I see my desired start page after adding /html/index.html to the end of the url.

Understanding how basic this problem is I took extra care to exhaust as many google searches as I could find relating to the topic before asking this question. My first question on StackO so my reputation is too low to link each page I found. My next attempt is to just start a brand new MVC project and painstakingly rearrange every single file that way. I'm confident that will work but I didn't want to leave this simpler method without learning from what I did wrong especially when I know the answer is going to derp-slap me in the face.

Have you tried to configure the default document under the configuration tab for your website in Azure portal?

在此处输入图片说明

在此处输入图片说明

With a lot of changing file locations around, clearing cache, and rebooting to avoid server and runtime errors, @hernandgr had the simple option I hadn't known about (shame on me) and funny enough couldn't successfully google about.

It turns out that I didn't need to do any of the steps I had tried to configure the start page beyond just changing it in the configuration tab in the Azure Management Portal. I deleted the global.asax file and the App_Code folder completely, didn't need to touch the web.config in any way and didn't need to implement MVC.

One thing to be noted was that making index.html my start page through Azure seemed to push it up a directory so my CSS, JS, LESS, fonts, and images folders had to be moved up as well to display the page properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM