Yes, it;s possible, try something like:
<customErrors mode="On">
<error redirect="~/GenericError.aspx" statusCode="404"/>
</customErrors>
However keep in mind that if you are hosting your web application in IIS 7, then you would need to define your custom errors as follows:
<system.webServer>
<httpErrors existingResponse="Replace" errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="GenericError.aspx" responseMode="Redirect" />
</httpErrors>
</system.webServer>
Edit 1
If you want to have a generic ASPX error page and display error messages depending on the HTML error status code, you could do the following:
(I just tested and it works)
Add the attribute redirectMode="ResponseRewrite"
to your customErrors
section:
<customErrors mode="On" defaultRedirect="~/GenericError.aspx" redirectMode="ResponseRewrite" />
In your generic error page (Page_Load event):
var ex = HttpContext.Current.Server.GetLastError();
this.lblMessage.Text += "<br/>" + ex.Message + ex.GetType().ToString();
if (ex is HttpException)
{
var nex = ex as HttpException;
this.lblMessage.Text += " " + nex.GetHttpCode().ToString();
switch (nex.GetHttpCode())
{
case 404:
// do somehting cool
break;
case 503:
// do somehting even cooler
break;
default:
break;
}
}