|
|
Subject:
Throwing ASP.NET's 404 error message (framework 1.0/1.1)
Category: Computers > Programming Asked by: joelnet-ga List Price: $10.00 |
Posted:
21 Dec 2004 16:07 PST
Expires: 03 Feb 2005 19:22 PST Question ID: 445749 |
I've created an http handler and have a condition that requires I throw a 404 message. I want to use ASP.NET's 404 message, just incase there is a custom 404 in the web.config I would like ASP.NET to handle the 404. So if there is no custom 404, it will be the basic IIS 404 page. And if there is a custom 404 in the web.config, it will redirect to that page. I tried asking this question on asp.net's forums, but didn't like the answer I received... here is the link http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=762031 I need it to satisfy both conditions (custom 404 and non custom 404). Ideally, the functionality I want would be if I could set a flag to ignore the request, but there doesn't seem to be one in IHttpHandler. So now I'm looking for another way. | |
| |
|
|
There is no answer at this time. |
|
Subject:
Re: Throwing ASP.NET's 404 error message (framework 1.0/1.1)
From: captainclaw-ga on 03 Jan 2005 05:18 PST |
Reponse object is having a StatusCode property which is the HTTP error code itself. So instead of redirecting the page using Response.Redirect() Set the response error code as 404 and set the Error message also. the code would be somewhat similar to : If ( your condition to check whether you need redirection) Then Response.StatusCode = 404 Response.StatusDescription ="File Not found" End If |
Subject:
Re: Throwing ASP.NET's 404 error message (framework 1.0/1.1)
From: captainclaw-ga on 03 Jan 2005 05:20 PST |
note that Response.Redirect will stop processing the remainging code in the page while this code snippet will not do that. So you need to make sure that the remaining code is not processed by putting those lines in the Else part of the condition. There may be another way for doing this.. But I did it this way when there was a need for this in one of my projects. |
Subject:
Re: Throwing ASP.NET's 404 error message (framework 1.0/1.1)
From: joelnet-ga on 03 Jan 2005 15:22 PST |
Ok, I believe the true answer is "it is not possible". |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |