Custom Error Page Not Displaying

For some reason, when I get an ASP.NET runtime error, it does not load my custom error page

<customErrors mode="On" defaultRedirect="app_offline.htm" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="app_offline.htm"/>
        <error statusCode="500" redirect="app_offline.htm"/>
</customErrors>

Whats in my web.config.

I am still getting this, although I am not loading my .htm page.

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>
+3
source share
5 answers

I am sure that app_offline.htm is a reserved file name in ASP.NET that will always be served if it is present on the server.

Try renaming it to error.htm file and update the block <customErrors />to match.

+7
source

I suspect that it is happening that ASP.NET cannot find your error page. The path to the error page file must be relative or absolute. So either:

<customErrors mode="On" defaultRedirect="~/app_offline.htm" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="~/app_offline.htm"/>
    <error statusCode="500" redirect="~/app_offline.htm"/>
</customErrors>

:

<customErrors mode="On" defaultRedirect="http://mysite.com/app_offline.htm" redirectMode="ResponseRewrite">
    <error statusCode="404" redirect="http://mysite.com/app_offline.htm"/>
    <error statusCode="500" redirect="http://mysite.com/app_offline.htm"/>
</customErrors>

.

+1

, = "."? - , :

CustomErrors = "."

0

, .NET 3.5, 4.0

0

. .

enter image description here

, RemoteOnly. , mode On. .

. , - CustomErrorAspxPage.aspx 404. enter image description here

, , 1) 2) 404 , . enter image description here

0

Source: https://habr.com/ru/post/1770463/


All Articles