0

My setup:

  • Windows 7 Ultimate
  • IIS 7
  • Visual Studio 2008

The scenario:

  • building a simple website locally
  • an exception is occurring in my app (this is perfect, since I'm trying to setup a custom error page)
  • without customErrors setup in the web.config file, I get detailed info about the error
  • WITH customErrors setup in the web.config file, I get the following page when my error occurs:

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.

There's more text than that, but I'm sure you've all seen it before. At this point, the URL is:

http://localhost/bluheron/Error.aspx?aspxerrorpath=/bluheron

So, it looks like it redirected to my error page (Error.aspx), but I'm not seeing my error text ("An error has occurred. Plese try again."). Instead, I'm getting a funky URL with loads of other text, including instructions on how to setup my web.config file, which, by the way, contains this:

<customErrors mode="On" defaultRedirect="Error.aspx" />

It's in the default location, which is inside the system.web section, which is inside configuation section.

By the way, my Error.aspx page is in the root of my app.

Can someone explain what the fancy URL is all about and why my simple error page isn't displaying?

Thanks, Jay

1 Answer 1

1

The error redirect is just what happens normally with customErrors...you can however disable this behavior and preserve the original url (not sending a 302 redirecting your user to the error page's url). This will execute/send the output of your error page:

Add redirectMode="ResponseRewrite" to your customErrors declaration:

<customErrors mode="On" defaultRedirect="Error.aspx" redirectMode="ResponseRewrite" />

If you're still getting the same behavior, there's something wrong with the whole application, and you should turn customErrors off and see what the issue is (this happens with an invalid web.config and many other cases).

Sign up to request clarification or add additional context in comments.

1 Comment

All seems to be well now, but I'm not sure what changed. Regardless, I appreciate the tip on the redirectMode attribute. Thanks, Nick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.