문제

I use Ajax.BeginForm.. It loads me partial view. This view have links. After view is loaded via ajax each link has href that ends with X-Requested-With=XMLHttpRequest. How can I disable automatic appending this parameter to my links?

도움이 되었습니까?

해결책

This header is sent by jQuery everytime you perform an AJAX request. You could try disabling it by globally subscribing to the ajaxSend handler and overriding its value:

$(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
    jqXHR.setRequestHeader('X-Requested-With', { 
        toString: function() { return ''; } 
    });
});

Notice that this will only set the value of the header to an empty string. It won't remove it from the request. A bug has been filed in jQuery asking to have the possibility to completely remove this request header and apparently it was rejected as not a bug.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top