web.config redirection returns 302 instead of 404

V

Vlad

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.
 
F

Fred Chateau

Vlad said:
<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

404 best practice 3
HTTP Error 404 1
Circumventing the 404 error 2
custom error 404 1
Question regarding detecting 404 Not Found 2
404 pages 4
404 error produces 302 response 0
Errors 302 and 304 3

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top