I want to add simple html pages as custom errors for IIS.
So i add 404.html and 500.html pages to project and add next configuration :
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<remove statusCode="500" />
<error statusCode="404" path="404.html" responseMode="File" />
<error statusCode="500" path="500.html" responseMode="File" />
</httpErrors>
Html pages are in Views/Shared folder.
But every time when i go to some unexisting path /foo/bar i just get error message The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. which is not mine.
For custom errors for ASP.Net i add next configuration :
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Home/404">
<error statusCode="404" redirect="~/Home/404" />
<error statusCode="500" redirect="~/Home/500" />
</customErrors>
and remove filters.Add(new HandleErrorAttribute()); this line from FilterConfig file.
I found that possible problem in correct path to html pages or change / to \ but noone solution that i found didn't help me.
I use IIS7+
Documentation to this setting is clumsy.
If responseMode of httpErrors error element is set to File, path is considered as a file path (use \ to separate directories).
Path needs to be relative to the directory that contains web.config file with this setting.
If html file is in Home directory (site root \Home\404.html) and
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With