Created
September 18, 2013 14:45
-
-
Save feanz/6610223 to your computer and use it in GitHub Desktop.
Expire Header WCF Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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