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

前端 未结 4 878
无人共我
无人共我 2021-02-07 19:58

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:29

    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();
    

提交回复
热议问题