4

I use Asp.net 4.

Here setting for my Web.Config file.

<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/ErrorPages/Oops.aspx">
    <error statusCode="404" redirect="/ErrorPages/404.aspx" />
</customErrors>

I need to apply the defaultRedirect url for any Exception, and use the redirectMode="ResponseRewrite" for only Page Not Found 404.

With this setting at the moment I can manage properly the Page Not Found (I'm able to get the 404.aspx page) but if an exception arise on any other page I get the "Internet Explorer cannot display the webpage" and I'm not able to reach the defaultRedirect Oops.aspx.

What I'm doing here wrong?

5
  • Does fetching oops.aspx work directly. An error in oops.aspx would cause and infinite redirect loop. Commented Sep 1, 2011 at 10:39
  • Yes oops.aspx work directly any idea? Commented Sep 1, 2011 at 10:40
  • Are you using the MVC framework? Commented Sep 1, 2011 at 10:42
  • I'm using Asp.Net 4 Web Forms in C# and Web Routing. Commented Sep 1, 2011 at 10:46
  • Does it work if you leave out the redirectMode attribute? Commented Sep 1, 2011 at 10:49

3 Answers 3

2

One problem with having an aspx page as the target of a custom errors redirect is that errors that aren't specific to a page (e.g. errors in global.asax; errors processing web.config) will also be thrown by the target page, which can result in an infinite redirect loop.

For this reason, it's often better to have a static html page as the target of at least the defaultRedirect.

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

Comments

1

Try putting the ~ in the redirect URL.

redirect="~/ErrorPages/404.aspx"

Comments

1

How many bytes is the error page content and does it set an HTTP status code other than 200 OK? In Internet Explorer with "Show friendly HTTP error messages" on, which is the default, custom error pages that have content under 512 bytes in length will be suppressed by the IE browser and replaced with the "friendly" error message.

To see if this is your problem, you can try turning off the "Show friendly HTTP error messages" option under Tools, Internet Options, Advanced, Settings. It'll be under the Browsing category in the Settings area.

If the page shows up with the option turned off, try turning it back on and changing your page to add an image or some other element that will make the size over 512 bytes long.

Comments

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.