Application_Error中判断404错误状态

  Application_Error 中如何获取http 404,500错误状态代码

void Application_Error(object sender, EventArgs e)
{
    Exception ex = Server.GetLastError();
    if (ex is HttpException)
    {
        if (((HttpException)(ex)).GetHttpCode() == 404)
            Server.Transfer("~/Error404.aspx");
    }
    // Code that runs when an unhandled error occurs
    Server.Transfer("~/DefaultError.aspx");
}

来源:http://blog.dmbcllc.com/aspnet-application_error-detecting-404s/

加支付宝好友偷能量挖...


评论(0)网络
阅读(89)喜欢(0)Asp.Net/C#/WCF