I'm running a Sitefinity CMS website on IIS 7. I'm seeing a couple of weird results when I'm trying to return a 404 status.
If I go to a URL like:
www.mysitefinitywebsite.com/test.co.uk (I realise this is an invalid address, but someone entered it into the CMS)
As the above is not an ASPX page, I believe IIS handles the error, with the following code:
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.aspx" responseMode="ExecuteURL" />
</httpErrors>
The url in the address bar remains the same, my custom 404 page (/404.aspx) page is displayed, however a http status code 200 is returned.
If however the following url is typed in:
www.mysitefinitywebsite.com/test.aspx - the ASPX error handler kicks in with the following config:
<customErrors mode="On" >
<error redirect="~/Sitefinity/nopermissions.aspx" statusCode="403" />
<error redirect="~/404.aspx" statusCode="404" />
</customErrors>
Again, my custom 404 page is displayed, however the url in the address bar changes to:
www.mysitefinitywebsite.com/404.aspx?aspxerrorpath=/test.aspx
And strangely if I check Firebug, a 302 code is returned for text.aspx and then a status of 200 for /404.aspx?aspxerrorpath=/test.aspx.
I don't completely understand whats going on here, it seems like IIS isnt responding with the status code at all - is this by design? Seems completely crazy!
If it is by design, presumably the only way to resolve it is to programatically return the correct response code?
Thanks in advance higgsy