Added Cache Attribute to stop IE caching data.
This commit is contained in:
parent
992f5cd1f4
commit
50acc1b136
@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web.Http.Filters;
|
||||||
|
|
||||||
|
namespace WindowsDataCenter.Helpers
|
||||||
|
{
|
||||||
|
public class CacheControlAttribute : System.Web.Http.Filters.ActionFilterAttribute
|
||||||
|
{
|
||||||
|
public int MaxAge { get; set; }
|
||||||
|
|
||||||
|
public CacheControlAttribute()
|
||||||
|
{
|
||||||
|
MaxAge = 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnActionExecuted(HttpActionExecutedContext context)
|
||||||
|
{
|
||||||
|
if (context.Response != null)
|
||||||
|
context.Response.Headers.CacheControl = new CacheControlHeaderValue()
|
||||||
|
{
|
||||||
|
Public = true,
|
||||||
|
MaxAge = TimeSpan.FromSeconds(MaxAge)
|
||||||
|
};
|
||||||
|
|
||||||
|
base.OnActionExecuted(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user