How to know if the request is ajax in asp.net in Application_Error()

前端 未结 4 1929
走了就别回头了
走了就别回头了 2021-02-07 19:49

How to know if the request is ajax in asp.net in Application_Error()

I want to handle app error in Application_Error().If the request is ajax and some exception is t

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-07 20:32

    You can also wrap the Context.Request (of the type HttpRequest) in a HttpRequestWrapper which contains a method IsAjaxRequest.

    bool isAjaxCall = new HttpRequestWrapper(Context.Request).IsAjaxRequest();
    

提交回复
热议问题