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?
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]);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With