Why is HttpContext Header Empty when trying to retrieve Header Information in MVC


Question: HttpContext Header is empty when attempt to retrieve data in C#, why is that?


Login to See the Rest of the Answer

Answer:
There is a chance that you are trying to retrieve the Keys from the HttpContext Header in a wrong way. Keep in mind that HttpContext Header Keys shows differently when you step in the HttpContext using a Debugger, however, when actually quering the Values you need to drop the "Header" section. For Example:

 

var UserAgent = httpContext.Request.Header["HeaderUserAgent"] //This is wrong and will not yeld any results
var UserAgent = httpContext.Request.Header["User-Agent"] //This is right, will yeld results.

- Hope this helps you.







For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]