By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,143 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

web.config redirection returns 302 instead of 404

P: n/a
Hello everybody,

I have a problem with custom error page. I' using a redirection in a
web.config file to a custom error page:

<customErrors mode="RemoteOnly" defaultRedirect="/_err/generic.aspx">
<error statusCode="404" redirect="/_err/not-found.aspx" />
</customErrors>

My custom error page "not-found.aspx" returns "HTTP Status Code: 404
Not found" which is OK.
But when I'm trying to check HTTP Status Code of non existing page it
is returns "HTTP Status Code: 302 Found" which means Temporary
Redirection. Any Ideas how to fix this problem? I want non existing
page return "HTTP Status Code: 404 Not found" as well.

Thank you,
Vlad.

Dec 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Vlad" <v.*******@gmail.comwrote ...
<customErrors mode="RemoteOnly" defaultRedirect="/_err/generic.aspx">
<error statusCode="404" redirect="/_err/not-found.aspx" />
But when I'm trying to check HTTP Status Code of non existing page it
is returns "HTTP Status Code: 302 Found" which means Temporary
Redirection. Any Ideas how to fix this problem? I want non existing
page return "HTTP Status Code: 404 Not found" as well.
I'm not sure I understand your problem but if it's what I think you're
saying, you can't rely on ASP.NET to handle this for you.

I believe what's happening is that ASP.NET is generating a 302 re-direct to
the 404 page. This is a totally backwards way of handling things and reveals
the ASP.NET development team's lack of experience with search engines, which
expect to see the 404 returned immediately.

Perhaps someone else can explain a method of handling this that doesn't
require custom HTTP error handling within each ASP.NET page. Otherwise I'll
be happy to post or send you some sample custom error handlers I use within
ASP.NET pages to generate custom errors directly.

Here's an example of direct custom error handling within an ASP.NET page:
http://hotelmotelnow.com/hotels.aspx/11292520/

Notice this page returns a "410 - Gone" in the header in response to bad
data. That is for the search engines. There is also text on the page for the
user, and diagnostics for me. Since there is no default custom redirect
defined in web.config, a non-existing page also returns a "404 - Not Found"
directly using ASP.NET's default error handler.

Here are two relevant examples of direct 404 error handling:
The first utilizes the same custom error handler as above.
http://hotelmotelnow.com/hotels.aspx/missing.htm
The second uses the ASP.NET default error handler, which works because
there are no custom error handlers defined in web.config.
http://hotelmotelnow.com/missing.aspx

Regards,

Fred Chateau

Dec 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.