Right now i am able to generate custom errors page with the code below at web config
<customErrors mode="On" defaultRedirect="Error404.aspx" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/Error404.aspx"/>
</customErrors>
This catches all non existing pages as long as they are not aspx
example : http://www.monstermmorpg.com/StackOverflow
Now if you make it this way
http://www.monstermmorpg.com/StackOverflow.aspx
the global asax is catching error
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
if (Server.GetLastError() != null)
if (Server.GetLastError().GetBaseException() != null)
{
Exception objErr = Server.GetLastError().GetBaseException();
ErrorLogger.LogError(Request.Url.ToString(), objErr.Message.ToString(), objErr.StackTrace.ToString());
if (objErr.Message.IndexOf("does not exist") != -1)
{
// Response.Redirect("http://www.monstermmorpg.com");
}
}
}
But at here it tells browser that the page you want to visit exists. Actually it is not exists. So i want to tell browser that the page you are looking for is 404.
How can i do that =?
If i redirect in global asax to the error404.aspx page, it gives me error that headers already sent
here error