日期:2014-05-18  浏览次数:20502 次

|M| 在Global中定义了错误处理能不能获得错误号
protected   void   Application_Error(Object   sender,   EventArgs   e)
{
        //   在出现未处理的错误时运行的代码
        Exception   error   =   HttpContext.Current.Server.GetLastError();
        String   Path   =   Request.Url.ToString();        
        Response.Redirect(String.Format( "/web/error/404page.aspx?Path={0}&Error={1}&Detail={2} ",   Path,   Server.UrlEncode(error.Message),Server.UrlEncode(error.ToString())));
}
上面是对所有错误的处理
但我想对404错误来特别处理
我怎么判断当前错误为404

谢谢

------解决方案--------------------
没有找到合适的属性...
------解决方案--------------------
c#中好像没有合适的属性,vb.net可以
------解决方案--------------------
只知道HttpWebRequest怎么取ErrorCode-_-#$
------解决方案--------------------
if( System.Web.HttpContext.Current.Response.StatusCode == 400)
....
------解决方案--------------------
是200
不是404
而且
我的错误都是出现200
-------------------------------

200说明是正确运行了,不出现404肯定是找到网页了。