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

前端 未结 4 1931
走了就别回头了
走了就别回头了 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:24

    You could use this.

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

提交回复
热议问题