How can I get the IIS substatus code from an Exception?

前端 未结 2 926
孤城傲影
孤城傲影 2020-12-19 08:11

I\'m handling exceptions with an HttpModule in a manner such as this:

int errorCode = 500;
HttpApplication httpApp = (HttpApplication)sender;

t         


        
2条回答
  •  遥遥无期
    2020-12-19 08:32

    You don't want the inner exception. You want:

    HttpException httpEx = httpApp.Server.GetLastError() as HttpException;
    if (httpEx != null)
        errorcode = httpEx == null ? 0 : httpex.GetHttpCode();
    

提交回复
热议问题