Most articles tell you how to search for the Asp.net website to customize the 404 error page:
In web. config, find system. Web and configure the following content.
<Customerrors mode = "on" error statuscode = "404" Redirect = "/404.htm">
</Customerrors>
In fact, after doing so, we will not be able to find the webpage header information for 404 not found, and we will get the webpage header information for 302 temporary redirection. You can use the check headers tool to view HTTP status codes.
So how to correctly configure the custom 404 error webpage for the Asp.net website?
Create a 404. ASPX page, and configure the following in customeerrors in the web. config file:
Customerrors redirectmode = "responserewrite"
Error statuscode = "404" Redirect = "~ /404. aspx "/
/Customerrors
Redirectmode has two attributes.
Responseredirect refers to the URL that redirects the user to the error page and changes the original URL to the error page.
Responserewrite is to direct the user to the error page without changing the original URL in the browser.
Then add the following code to the page_load event in the 404. aspx. CS file:
Protected void page_load (Object sender, eventargs E)
{
Response. Status = "404 Not Found ";
}
After this setting, the HTTP status code is 404 Not found.