Mattias
Mattias

Reputation: 3169

How to retrieve Ajax header in this asp.NET web api method?

    [Route("api/test")]
    public IEnumerable<Tests> GetTests()
    {
         //Retrieve ajax header here?? 
        return ClassTestfuntions.Testmethod();     
    }

I have this asp.net web api method that i use to GET a list of rows from my db, im now also sending an header to this method within my ajax http get call but im not sure how to retrieve it's value, any help or input highly appreciated, thanks!

Upvotes: 2

Views: 1035

Answers (1)

hutchonoid
hutchonoid

Reputation: 33305

You can pull it from the request headers as follows:

var headers = Request.Headers.GetValues("AjaxHeader");
var ajaxHeader = headers.FirstOrDefault();

Upvotes: 1

Related Questions