My 404 Custom setup shows up as a blank page if it has an asp extension. If I change the extension of the custom error page to .html, the custom error page shows correctly.
this is my web.config file
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" existingResponse="Auto">
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error_pages/error500.asp" responseMode="ExecuteURL" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/error_pages/error404.asp" responseMode="ExecuteURL" />
</httpErrors>
I cant figure this out... driving me nuts
If you like to redirect when the error happens, use...
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/time.asp" responseMode="Redirect" />
</httpErrors>
You may also hide the redirection, by using...
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/time.asp" responseMode="ExecuteURL" />
</httpErrors>
You can also use Custom Errors (of ASP.NET) like so...
<system.web>
<customErrors mode="On">
<error redirect="time.asp" statusCode="404" />
</customErrors>
</system.web>
Related
I've got custom error mode "On" in my web.config. However, the ASPX error page still shows for certain kinds of particular URL
Not OK
https://example.com/*~1*%5ca.aspx <-- Return 404 - File or directory not found.
OK
https://example.com/abc.aspx <-- can redirect to custom page
I'm using Windows Server 2012 Azure. I disabled the NtfsDisable8dot3NameCreation in the registry, but still no luck. What can be the root cause?
My web config
<customErrors mode="On" defaultRedirect="~/error/Error403.html">
<error statusCode="400" redirect="~/error/Error400.html" />
<error statusCode="401" redirect="~/error/Error400.html" />
<error statusCode="402" redirect="~/error/Error400.html" />
<error statusCode="403" redirect="~/error/Error403.html" />
<error statusCode="404" redirect="~/error/Error404.html" />
<error statusCode="500" redirect="~/error/Error500.html" />
<error statusCode="501" redirect="~/error/Error501.html" />
<error statusCode="502" redirect="~/error/Error502.html" />
<error statusCode="503" redirect="~/error/Error503.html" />
<error statusCode="504" redirect="~/error/Error504.html" />
</customErrors>
<httpErrors errorMode="Custom" existingResponse="Auto" defaultResponseMode="ExecuteURL">
<remove statusCode="400" subStatusCode="-1"/>
<remove statusCode="401" subStatusCode="-1"/>
<remove statusCode="402" subStatusCode="-1"/>
<remove statusCode="403" subStatusCode="-1"/>
<remove statusCode="404" subStatusCode="-1"/>
<remove statusCode="500" subStatusCode="-1"/>
<remove statusCode="501" subStatusCode="-1"/>
<remove statusCode="502" subStatusCode="-1"/>
<remove statusCode="503" subStatusCode="-1"/>
<remove statusCode="504" subStatusCode="-1"/>
<!--<error statusCode="500" path="error\InternalServerError.htm"/>
<error statusCode="404" path="error\PageNotFound.htm"/>-->
<error statusCode="400" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error400.html" />
<error statusCode="401" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error400.html" />
<error statusCode="402" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error400.html" />
<error statusCode="403" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error400.html" />
<error statusCode="404" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error404.html" />
<error statusCode="500" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error500.html" />
<error statusCode="501" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error501.html" />
<error statusCode="502" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error502.html" />
<error statusCode="503" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error503.html" />
<error statusCode="504" prefixLanguageFilePath="" responseMode="ExecuteURL" path="/error/Error504.html" />
</httpErrors>
I think you should get 400 error more than 404 error because "*" is not a valid request.path for .NET runtime and the exception was thrown from CLR. That's why IIS custom error page would never work.
Please try to set requestPathInvalidCharacters to null or manual specify invalid characters for your runtime.
<system.web>
<compilation targetFramework="4.8" />
<httpRuntime requestPathInvalidCharacters=""/>
<customErrors mode="RemoteOnly">
<error redirect="https://www.jokiesd.com/404.aspx" statusCode="404" />
</customErrors>
</system.web>
Edit:
I can' reproduce this issue on my 2012 server. Have you tried to replace the URL to abosolute URL?
I have a Umbraco site and have configured the custom error pages for 404 (page not found) and 500 (internal server errors). When I try to access a page which is not existing, I get the custom 404 page. But the HTTP status code returned is 200 rather than 404. Can someone suggest a solution, I am looking for HTTP Status code 404 to be returned.
I have the following mentioned in the Config file
<customErrors defaultRedirect="errorPages/500.html" mode="RemoteOnly">
<error statusCode="404" redirect="errorPages/404.html" />
<error statusCode="403" redirect="errorPages/403.html" />
<error statusCode="500" redirect="errorPages/500.html" />
<error statusCode="404" redirect="errorPages/503.html" />
</customErrors>
<httpErrors existingResponse="Replace" errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/errors/404" responseMode="ExecuteURL" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" prefixLanguageFilePath="" path="/errors/403" responseMode="ExecuteURL" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" prefixLanguageFilePath="" path="/errors/500" responseMode="ExecuteURL" />
</httpErrors>
Thanks
I have web.config settings like this
<customErrors mode="On" >
<error statusCode="404" redirect="~/404" />
<error statusCode="403" redirect="~/500" />
<error statusCode="500" redirect="~/500" />
</customErrors>
and for httperrors
<httpErrors errorMode="Custom" >
<error statusCode="400" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\bad_request.html" />
<remove statusCode="401" subStatusCode="-1" />
<error statusCode="401" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\unauthorized.html" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\forbidden.html" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\not_found.html" /><remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\method_not_allowed.html" /><remove statusCode="406" subStatusCode="-1" />
<error statusCode="406" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\not_acceptable.html" />
<error statusCode="407" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\proxy_authentication_required.html" /><remove statusCode="412" subStatusCode="-1" />
<error statusCode="412" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\precondition_failed.html" />
<error statusCode="414" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\request-uri_too_long.html" /><error statusCode="415" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\unsupported_media_type.html" />
<remove statusCode="500" subStatusCode="-1" /><error statusCode="500" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\internal_server_error.html" />
<remove statusCode="501" subStatusCode="-1" /><error statusCode="501" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\not_implemented.html" />
<remove statusCode="502" subStatusCode="-1" /><error statusCode="502" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\bad_gateway.html" />
<error statusCode="503" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\maintenance.html" />
</httpErrors>
On 404 Error. Skipping 404 page and goes to .aspxerrorpath= page.aspx
and writing
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
I want to show my customized 404, 500 error page. What is the wrong
In short, in production it is possible to completely get rid of the "system.web -> customErrors" section, which is almost kept for the compatibility purposes (check the What is the difference between customErrors and httpErrors? thread to learn more), and where you also specify redirects. Then, specify the necessary redirects and custom error pages within the "system.webServer -> httpErrors" section only. Make sure that these HTML files exist on the web server and are available via the relative paths (or these pages exist inside one of a parent web app on the same web server, so that these "errors" settings are inherited).
Solution Explorer:
~/YourWebApp
...
not_found.html
Web.config
Web.config (for the 404 status code error):
<!--Dev: For Visual Studio Mode-->
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="~/not_found.html" />
</customErrors>
</system.web>
<!--Prod: For IIS Mode-->
<system.webServer>
<httpErrors errorMode="Custom">
<!--<error statusCode="404" path="C:\Inetpub\vhosts\domain.win2012.tld\error_docs\not_found.html" />-->
<error statusCode="404" path="~/not_found.html" responseMode="Redirect" />
</httpErrors>
</system.webServer>
I designed a website that have one area (manager) for administrators. In main web site i customized error pages easily in webconfig. with this:
<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL">
<remove statusCode="400"/>
<remove statusCode="401"/>
<remove statusCode="403"/>
<remove statusCode="404"/>
<remove statusCode="408"/>
<remove statusCode="409"/>
<remove statusCode="500"/>
<error statusCode="400" responseMode="ExecuteURL" path="/Error/400"/>
<error statusCode="401" responseMode="ExecuteURL" path="/Error/401"/>
<error statusCode="403" responseMode="ExecuteURL" path="/Error/403"/>
<error statusCode="404" responseMode="ExecuteURL" path="/Error/404"/>
<error statusCode="408" responseMode="ExecuteURL" path="/Error/408"/>
<error statusCode="409" responseMode="ExecuteURL" path="/Error/409"/>
<error statusCode="500" responseMode="ExecuteURL" path="/Error/500"/>
</httpErrors>
now i want to show administrators that are in manager area some different custom error pages (like their panels).
can someone tell me how can i do that?
EDIT:
I put a new web.config file in /Areas/Manager folder.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL">
<remove statusCode="400"/>
<remove statusCode="401"/>
<remove statusCode="403"/>
<remove statusCode="404"/>
<remove statusCode="408"/>
<remove statusCode="409"/>
<remove statusCode="500"/>
<error statusCode="400" responseMode="ExecuteURL" path="/Manager/Error/400"/>
<error statusCode="401" responseMode="ExecuteURL" path="/Manager/Error/401"/>
<error statusCode="403" responseMode="ExecuteURL" path="/Manager/Error/403"/>
<error statusCode="404" responseMode="ExecuteURL" path="/Manager/Error/404"/>
<error statusCode="408" responseMode="ExecuteURL" path="/Manager/Error/408"/>
<error statusCode="409" responseMode="ExecuteURL" path="/Manager/Error/409"/>
<error statusCode="500" responseMode="ExecuteURL" path="/Manager/Error/500"/>
</httpErrors>
</system.webServer>
</configuration>
i even put httpErrors part in ~/Areas/Manager/Views/web.config. but always for errors i see /Error/ErrorCode instead /Manager/Error/ErrorCode page.
Create a new web.config that goes in the Admin/Manager folder. That folder can then have it's own set of httpErrors that only apply to pages located in that folder.
These are the codes in web.config:
<system.web>
<customErrors mode="Off" >
</customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<clear />
<error statusCode="404" prefixLanguageFilePath="" path="/ResourceNotFound" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/ResourceNotFound" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
The above settings will redirect httpError of 404 and 500 only.
But instead of manually add all the error code of 400, 401, 403....etc..etc...
Can we just set it redirect all errors to the same url without typing all the error code?
<error statusCode="400" .....
<error statusCode="401" .....
<error statusCode="403" .....
<error statusCode="404" .....
<error statusCode="xxx" ....
The httpErrors section has defaultPath attribute.
<system.webServer>
<httpErrors defaultPath="Error.html" defaultResponseMode="File">
<clear />
</httpErrors>
</system.webServer>
http://www.iis.net/configreference/system.webserver/httperrors
However, I don't use it, because defaultPath is locked in IIS Express by default. Need to edit %homepath%\Documents\IISExpress\config\applicationHost.config to unlock it.
<httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
<!-- ... -->
</httpErrors>
try this,
add in web.config file.
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultResponseMode="File" >
<remove statusCode="500" />
<error statusCode="500" prefixLanguageFilePath="C:\Contoso\Content\errors"
path="500.htm" />
</httpErrors>
</system.webServer>
and
<httpErrors existingResponse="Replace" defaultResponseMode="ExecuteURL" errorMode="Custom">
<remove statusCode="404" />
<error statusCode="404" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<remove statusCode="401" />
<error statusCode="401" path="/Account/Login.aspx" responseMode="ExecuteURL"/>
<remove statusCode="501"/>
<error statusCode="501" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<remove statusCode="411"/>
<error statusCode="411" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
<remove statusCode="403"/>
<error statusCode="403" path="/ErrorPages/Oops.aspx" responseMode="ExecuteURL"/>
</httpErrors>
and more about this http://www.iis.net/configreference/system.webserver/httperrors