2

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 1

8

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);
Sign up to request clarification or add additional context in comments.

2 Comments

yes, 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!
So maybe message inspector could do the magic: link looks promising but I've never work with these.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.