"IanW" <sp*******@tiscali.co.ukwrote in message
news:21**********************************@b1g2000h sg.googlegroups.com...
[top-posting corrected]
>>Should I create a 404.aspx page and server.transfer to that, or is
there some other way?
HttpContext.Current.Response.StatusCode = 404;
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteR equest();
return;
So do I put this code in the products.aspx page?
Add it to your URL rewriting code, which I'm assuming is in
Application_BeginRequest...
I have the following in web.config, but the current solution does not
redirect to the actual error page. How would I accomplish that?
<customErrors mode="Off">
<error statusCode="404" redirect="~/404.aspx"/>
</customErrors>
Firstly, you've actually switched custom errors off, so this will never
work. See here for more details:
http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx
Secondly, the redirection will only happen for filetypes which ASP.NET knows
about e.g. .aspx etc. Other filetypes e.g. .htm, .html will never be caught
by this unless they have been specifically added to the list of filetypes
which IIS sends to ASP.NET for processing...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net