Skip to content

Instantly share code, notes, and snippets.

@feanz
Created September 18, 2013 14:45
Show Gist options
  • Save feanz/6610223 to your computer and use it in GitHub Desktop.
Save feanz/6610223 to your computer and use it in GitHub Desktop.
Expire Header WCF Service
public static class Expires
{
public static void Set(int seconds)
{
var response = WebOperationContext.Current.OutGoingResponse;
if(response != null)
{
var expires = DateTime.UtcNow.AddSeconds(seconds).ToEpireString();
response.Headers.Add(HttpReponseHeader.Expires, expires);
}
}
}
public static class Extensions
{
public static string ToExpireString(this DateTime dateTime)
{
return dateTime.ToString("ddd, dd MMM yyy HH:mm:ss 'GMT'");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment