Hello I am trying to do a redirect if the response is a 404 but it is not working as expected, can you experts see the issue?. It still goes to the generic 404
in my Global.asax
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (Response.Status == "404 Not Found")
{
string notFound = "~/custom_notfound.aspx";
Response.Redirect(notFound);
}
}
UPDATE
Tried so far
(Response.Status == "404 Not Found")
(Response.Status == "404")
(Response.StatusCode == 404)
You can also use the web.config customerrors section - as shown here
e.g. In the system.web section,
<customErrors mode="On" defaultRedirect="/custom_error.aspx">
<error statusCode="404" redirect="/custom_notfound.aspx" />
</customErrors>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With