tags:

views:

33

answers:

4

For some reason, when I get an ASP.NET runtime error, it's not loading 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>

That's in my web.config.

I'm still getting this though and it's not loading my error .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's <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>
A: 

I suspect what's happening is that ASP.NET can't find your custom error page. The path to your error page file needs to 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>

Or:

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

Should solve your problem.

Mark B
isn't just the page name relative already?
CoffeeAddict
you don't always need to use ~. Sure you can but you can also use redirect="app_offline.htm" as it's already in the root of my application and I'm hitting root when I go to my site already...no need for the extra ~
CoffeeAddict
thanks for the try though...and your time.
CoffeeAddict
“I'm hitting root when I go to my site already...no need for the extra ~” Yes, but if you go to a URL that *isn't* relative to the root and an error occurs, then the relative path to `app_offline.htm` will no longer be correct.Anyway, glad you figured it out.
Mark B
A: 

Do you get details of the actual error if you set mode="Off"? If you still get the same default error page, you might find the solution in this post:

http://stackoverflow.com/questions/101693/customerrors-modeoff

awe
+2  A: 

I'm pretty sure that app_offline.htm is a reserved filename in ASP.NET that will always be served if present on the server.

Try renaming it to error.htm and updating your <customErrors /> block to match.

James Simm
A: 

Problem was my site was running under .NET 3.5 when it's a 4.0 app

CoffeeAddict