I am trying to use simple html page when 503 service unavilable error comes.
I am using below in web.config's system.webservers
<httpErrors errorMode="Custom">
<remove statuscode="503" substatuscode="-1">
<error statuscode="503" responseMode="File" path="Views/Shared/IISError.htm">
</httpErrors>
This is nt working. I am still getting IIS default page when I stop my application.
I am using mvc3, razor application.
You can configure the <httpErrors> element at the server level in the ApplicationHost. config file and at the site and application level in the appropriate Web. config file.
customErrors are a legacy (backwards compatable) element, used by Visual Studio Development Server (aka. VSDS or Cassini). httpErrors are the new element which is only used by IIS7. This highlights the possible problem when developing ASP.NET websites while using VSDS instead of the local IIS.
When there is an error page thrown in IIS (like 404 for example) it can expose relative or absolute paths on the Kaseya server. This is a security concern so a good security practice is to hide those paths to remote viewers as there is no need for them to see it.
To prevent unauthorized users from viewing this privileged information, detailed error pages must not be seen by remote users. This setting can be modified in the errorMode attribute setting for a Web site's error pages. By default, the errorMode attribute is set in the Web.
It took me a while to figure this out... but I think this might help you:
First of all to configure errors in IIS 7 you need to do it using the following section:
<system.webServer>
<httpErrors existingResponse="Replace" defaultResponseMode="Redirect" errorMode="Custom">
<remove statusCode="503"/>
<error statusCode="503" responseMode="Redirect" path="Views/Shared/IISError.htm"/>
</httpErrors>
</system.webServer>
This configuration works, however you might receive an error indicating that you cannot override the httpErrors
section, if that's the case, follow the next steps:
Open the C:\Windows\System32\inetsrv\config\applicationHost.config
Change:
<section name="httpErrors" overrideModeDefault="Deny" />
To:
<section name="httpErrors" overrideModeDefault="Allow" />
The question is, are you using VisualStudio Development Server or IIS7 Express ?
if you are using Cassini (VSDS) then you should try with
<customErrors mode="On" >
<error statusCode="503" redirect="/Views/Shared/Error.htm"/>
</customErrors>
because httpErrors is a new structure that is handled only by IIS7. You can find some more info on : What is the difference between customErrors and httpErrors? and http://www.iis.net/ConfigReference/system.webServer/httpErrors
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