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

前端 未结 4 693
无人共我
无人共我 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条回答
  •  梦毁少年i
    2021-02-07 20:15

    You could use this.

        private static bool IsAjaxRequest()
        {
            return HttpContext.Current.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
        }
    

提交回复
热议问题