![]() I was able to get around this issue by using the following setup in asp.net webforms using. Header Spy Response: HTTP/1.1 404 Not Found Here is a post that goes into some more details that may be of use to you and your problem, my test does do a redirect to the new page so the url of the requested file is pretty much lost (except its in the query string). Now if I go to a page that is not processed by Asp.Net, like a htm file, the custom page does not show and the 404 that is configured by IIS is displayed. Thats about it, if I go to any page extension that is processed by Asp.Net and does not exist, my fiddler log clearly shows a 404, here is the header: HTTP/1.1 404 Not Found Protected void Page_Load(object sender, EventArgs e) I can't tell you what is wrong with your app, but I can tell you what I did:ġ) Edited the web.config for custom errors: Ģ) Added a 404.aspx page and set the status code to 404. I was able to get a test web app to work fine, well it at least displayed the custom error page and returned a 404 status code. More work could be done to find out exactly when the master page is setting the status, but I'll leave that to you. protected override void Render(HtmlTextWriter writer) I got it to work by setting the status code later in the pages lifecycle, obviously the rendering of the master page was resetting it, so I overrode the render method and set it after the render was complete. The problem, it turned out, was the use of the master page. I would really rather use the code behind option but I can't seem to make it work without putting a the hack inline code in the design / layout. And I am configuring custom error pages in my web.config. I found however that if I hard code the following code into the design code it will work properly. The solution I want to work is adding the following two lines to the code behind Page_Load method of the custom 404 page. So I found many articles on the issue but the solution I want didn't seem to work. This is consider a soft 404 or false 404. It displayed the correct custom page and told the browser that everything is OK. After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |