Link to home
Start Free TrialLog in
Avatar of ctudorprice
ctudorprice

asked on

A REAL "404 Not Found" response in ASP.NET?

Hi,
I want to create a 404 page that really sends a "404 Not Found" status that includes custom content.

Problem is that when CustomErrors is on in web.config, the errorhandling actually sends a 302 response and redirects the browser using 'Location: /mycustom404.aspx?aspxerrorpath=/asdffd.aspx' in the header. Problem with this is that I want to send Google et. al. a real "404 Not Found" status, not a "302 Found" status but I also want the page to be user-friendly and not rely on the generic 404 IIS page. I tried putting response.status="404 Not Found" on my custom404.aspx page, but all that does is tell Google that the custom404.aspx page can't be found, not the original.

Anyone have any ideas? I want Google and others to de-index pages that don't exist (thus avoiding possible duplicate content issues) but I don't want stranded users.

Thanks
Avatar of raterus
raterus
Flag of United States of America image

What about?

Response.StatusCode = 404
Avatar of ctudorprice
ctudorprice

ASKER

tried that - same effect ast the response.status="404 Not Found".

iis doesn't find a page on my site and thus looks in web.config to see if I have custom errors. If configured, it redirects the user to that page, using the 302 and a location. I can send a 404 then but that only indicates that the custom error page was not found, not the originally requested page.

ASKER CERTIFIED SOLUTION
Avatar of raterus
raterus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks - I vaguely remember trying this (or a similar approach) and I found that when I configured the IIS 404 to execute my .aspx, it was executed out-of-process - or session - which was a bit of a drag. But I'll try this again - maybe I was doing something wrong. Thanks. I'll let you know how it goes.