c# - How to set HTTP cache-control from .net web service? -
after I inherited a class ( I am trying to set the cache-control header in response to the I get the standard The web server still responds with the default cache-control. I suspect that ASP.NET web services want to adopt the web method after its execution. The suggestion below is not applicable in my situation to use WebMethod's CacheDuration feature. Any advice? This feature should be included in your move. If you want to use context specifically then You will be safe to access references until it is empty. A simple check will solve for you
[WebMethod, SoapHeader ("title", direction = SoapHeaderDirection.In)] [SoapDocumentMethod ("http://www.myservices.com/Services/ 1.1 #getMediaMetadata ")] Public MediaMetadata getMediaMetadata (String ID) {New MediaService (return). GetMetadata (ID); }
HttpResponse.Cache.SetMaxAge
Executing the service produces a default header:
cache-control: private, max-age = 0
Cache SetMaxAge
with a hardcoded header:
HttpContext.Current.Response.AddHeader ("cache-control", "private, max age =" + (int) ttl totalSeconds) ;
[WebMethod (CacheDuration = 60), SoapHeader ("title", direction = SoapHeaderDirection. In]] SoapDocumentMethod ("http://www.myservices.com/Services/1.1####################################) Public MediaMetadata getMediaMetadata (String ID) {New Media Service Return () GetMetadata (ID); }
Context.Response.Cache.SetMaxAge (TimeSpan.FromSeconds (60));
Comments
Post a Comment