ASP.NET MVC - What does IsAjaxRequest() actually mean?

后端 未结 2 1331
不知归路
不知归路 2020-12-10 10:37

I had previously created a method on my base controller:

public bool IsJsonRequest()
{
    var acceptTypes = Request.AcceptTypes;
    return acceptTypes != n         


        
2条回答
  •  暖寄归人
    2020-12-10 11:11

    It checks for the X-Requested-With (HTTP_X_REQUESTED_WITH) header being set to XMLHttpRequest. This header is set by jQuery and a number of other javascript frameworks when making AJAX requests.

提交回复
热议问题