In my global asax, I always check what type of http error it is ...
then go to the page with the correct error specified in web.config I like to process ordinary suspects, 404 (lost page) and 500 (server error)
http importaint, , :
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
my web.config .
<customErrors mode="On" defaultRedirect="~/error.aspx" >
<error statusCode="404" redirect="~/lost.aspx" />
<error statusCode="500" redirect="~/error.aspx" />
</customErrors>
, , , , , .
, ,
-.
, , 401/403?
protected void Application_Error(object sender, EventArgs e)
{
var context = Context;
var error = context.Server.GetLastError() as HttpException;
var statusCode = error.GetHttpCode().ToString();
var config = (CustomErrorsSection)WebConfigurationManager.GetSection("system.web/customErrors");
if (config.Mode == CustomErrorsMode.On ||
(config.Mode == CustomErrorsMode.RemoteOnly && context.Request.Url.Host != "localhost"))
{
context.Response.StatusCode = error.GetHttpCode();
if (config.Errors[statusCode] != null)
{
HttpContext.Current.Server.Transfer(config.Errors[statusCode].Redirect);
}
else
HttpContext.Current.Server.Transfer(config.DefaultRedirect);
}
}
, i, , -... , http- 302, , ... 200 (ok).
302 → 200, 302 → 404 , 404...
404 , http:
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Status = "404 Lost";
Response.StatusCode = 404;
}
, , , , web.config... http://helephant.com/2009/02/improving-the-way-aspnet-handles-404-requests/
, 404 404 . , , , .
404. Soft 404 arent , , 404, 404 - , - , . , , , .
, 404 , , , 404 , . 404 Google -:
server.clearerror() global.asax?
web.config error.aspx 500, - defaultredirect
- 2,
/ ,
.
,
...
, .
. 403, 401, 400 (
,
)
error.aspx lost.aspx.
- -
.
, , ,
.
,
. log
, ,
...
.