I'm working with WCF with SOAP message architecture. My services are using BasicHttpBinding for transporting my SOAP messages. I need to add 2 different HTTP headers(Origin and Cache control) to HTTP response. I know that I can do that in Global.asax file in case of enabling aspNetCompatibilityEnabled, but there is a problem - I'm using windows service for hosting my WCF. aspNetCompatibilityEnabled works only under IIS. Can anybody help me with approach?
Asked
Active
Viewed 6,758 times
1 Answers
7
I believe this article is about what you want to do: here. You can do something like this:
var context = WebOperationContext.Current;
HttpResponseHeader cacheHeader = HttpResponseHeader.CacheControl;
String cacheControlValue = String.Format("max-age={0}, must-revalidate", maxCacheAge);
context.OutgoingResponse.Headers.Add(cacheHeader, cacheControlValue);

Jan Barta
- 450
- 2
- 8
-
1yes, but in this case i will need to add such signature in every web method. Maybe there is some centralized place for such purpose. And thnx btw! – aturch Jul 15 '14 at 12:38
-
2So maybe message inspector could do the magic: [link](http://weblogs.asp.net/paolopia/writing-a-wcf-message-inspector) looks promising but I've never work with these. – Jan Barta Jul 15 '14 at 12:47