6

I've fired up the WCF REST starter kit and am trying to access the HTTP headers on the incoming request. I've looked at OperationContext.Current.IncomingMessageHeaders but either it doesn't hold them or I'm accessing it wrong.

How do I list the HTTP headers?

1 Answer 1

11

Eventually found the answer.

using System.ServiceModel.Web; protected override IEnumerable<KeyValuePair<string, SampleItem>> OnGetItems() { WebHeaderCollection headers = WebOperationContext.Current.IncomingRequest.Headers; foreach (string key in headers.Keys) { logger.Debug("header " + key + "=" + headers[key]); } } 
Sign up to request clarification or add additional context in comments.

1 Comment

how do you implement this in the .svc file or in the method ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.