1

When deploying a single html page on a Windows Azure web app, I noticed some of the default IIS behaviors for ASP.Net still apply, even if there is no actual ASP.Net application deployed on the server. The specific case I don't understand is if the client enter an invalid addresss like https://www.mysuperwebsite.com/>. By default, IIS consider this address as unsecure (more info here and here), which is totally fine to me.

The problem I have from that point is I want to display my own error page, not the default one from IIS.

As my site contains no ASP.Net related stuff, I was on the impression that only the httpErrors section of the web.config applies in my case. But with the following config, I wasn't able to display my error page:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="Custom" defaultResponseMode="File" defaultPath="error.html">
            <remove statusCode="400"/>
            <error statusCode="400" responseMode="File" path="error.html"/>
        </httpErrors>
    </system.webServer>
</configuration>

The only way I got it to work was by adding the next section:

<system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="error.html" />
</system.web>

But from my understanding customErrors section is dediacted to handle errors generated by ASP.Net code, which I don't have in my case...

  • I confirmed with postman the error code returned by IIS in that case is 400 - bad request.
  • I also tested my error paged configured in httpErrors by creating a folder on the web app and trying to list its content: in that case the httpErrors section is driving the displayed error page.
  • Files for simple reproduction available here.
GGirard
  • 1,145
  • 1
  • 13
  • 33

0 Answers0