How to pass custom header with ajax call in .Net MVC?
Answers (2)
Add AnswerAdd the below code before your ajax call. This will set the header for all the ajax calls on your page. If you need to pass the same headers with multiple ajax calls then you can use this way.
$.ajaxSetup({ beforeSend: function (xhr) { xhr.setRequestHeader('YOUR_HEADER_NAME', 'VALUE' ); xhr.setRequestHeader('YOUR_HEADER_NAME_2', 'VALUE_2' ); } });