1

I add a custom header to each of my calls made from an Angular service to pass a system Id to my application

$http.defaults.headers.common["SystemId"] = "1";

When using Fiddler I can see that the custom header is added

enter image description here

enter image description here

On the server side I'm trying to retrieve this header from a user defined C# class by doing the following

if (HttpContext.Current != null)
{
    systemIdHeader = HttpContext.Current.Request.Headers["SystemId"];                                
}

The HttpContext.Current object is set but the Headers array is empty. Is there any reason why this header will go missing?

2
  • Is whole collection empty or maybe SystemId is missing? Commented Jul 21, 2015 at 13:42
  • The entire collection is empty Commented Jul 21, 2015 at 13:43

1 Answer 1

1

Ok I found the problem. I'm posting to an oAuth token endpoint which is making use of the OAuthGrantResourceOwnerCredentialsContext, so I had to use

_oAuthGrantResourceOwnerCredentialsContext.Request.Headers["SystemId"];

instead of

HttpContext.Current.Request.Headers["SystemId"];  
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.