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?
1 Answer
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);