Reputation: 335
While I am doing ajax call, I want access header value present in WEBAPI,How to call the header value.
Header is of this fromat in WEBAPI:
HttpContext.Current.Response.AppendHeader("SECURITY_TOKEN_KEY", TokenManager.CreateToken(objUserAuthentication.SUA_Login_Id));
Upvotes: 2
Views: 924
Reputation: 269
Hi simply you can use getAllResponseHeaders method to get all header value.Then you can filter out the required one based on key name.
var geturl;
geturl = $.ajax({
type: "GET",
url: 'http://....',
success: function () {
alert("done!"+ geturl.getAllResponseHeaders());
}
});
Upvotes: 0
Reputation: 759
You can pull it from the request headers as follows:
var headers = Request.Headers.GetValues("AjaxHeader");
var ajaxHeader = headers.FirstOrDefault();
Hope it helps.
How to retrieve Ajax header in this asp.NET web api method?
Upvotes: 1