简体   繁体   中英

Configuring web.config for Azure Web Sites

I'm new to Azure WebSites. Looking to personalise 400 series pages. From reading I understand in IIS this is configured using a web.config file.

While there is lots of great supporting documentation on how to configure this file, it doesn't actually tell me where the file is meant to be saved on an Azure hosted platform. I've tried D:\\home\\site\\wwwroot\\web.config but as soon as I put some basic configuration like:

<?xml version="1.0"?>
<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="on"/>
<httpErrors>
<remove statusCode="401" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />                
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="401" path="http://foo.com/default.htm" responseMode="Redirect" />
<error statusCode="403" path="/errors/403.htm" responseMode="ExecuteURL" />
<error statusCode="404" path="/somedir/oops404.htm" responseMode="ExecuteURL" />                
<error statusCode="500" path="/somedir/500.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.web>
</configuration>

The site begins to return a 500 (503 to be precise).

I've tried restarting the instance using the Manage console but still have the same issue.

Any advice would be greatly appreciated, I'm trying to configure default error pages and CORS for the site.

<httpErrors> is a child element of <system.webServer> (not <system.web> ) - see details at HTTP Errors in the IIS.net . Move <httpErrors> to <system.webServer> . For example...

<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL" >
    <remove statusCode="403"/>
    <remove statusCode="404"/>
    <remove statusCode="500"/>
    <error statusCode="403" responseMode="ExecuteURL" path="/Error403" />
    <error statusCode="404" responseMode="ExecuteURL" path="/Error404" />
    <error statusCode="500" responseMode="ExecuteURL" path="/Error500" />
  </httpErrors>
</system.webServer>

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