Question : status code for html page that doesn't exist

Is it possible in asp.net to find out status code of the static page that doesn't exist. I changed IIS settings to process every single request *.html pages etc ... and when i type in the address bar somename.html page that doesn't exist, the code hits application begin request method and when I step through the code, the Exception ex = Server.GetLastError(); returns null and then IIS takes over and redirect to the mapped 404 page. Is it possible to find out if static page doesn't exist on the application level. The none existent .aspx page will return 404 status code. in the application error or application begin request block.

I guess I could use file system object and find out if requested static page exists and then set status code to 404. Any other solutions that would allow me to get the correct status code (404) for static pages that do not exist in the application?

Answer : status code for html page that doesn't exist

Hi TransBind

you can use IIS management to define your 404 page, as seen in the image,

you go to IIS, right click on the website --> go to properties --> Custom errors tab and change

or if you want to control it programmbly, you can use HTTP Handlers and HTTP Modules in ASP.NET

check out these links
http://www.15seconds.com/issue/020417.htm
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=392
http://www.developerfusion.com/article/4643/implementing-http-handlers-in-aspnet/

read about  HTTP Handlers and HTTP Modules in ASP.NET or google it and you will find alot of resources
Random Solutions  
 
programming4us programming4us