I would like to avoid caching if the user is logged in with forms authentication in the admin group.
I redefined the cache attribute and applied it at the controller level. However, the NonAdmin method is not called through validationcallback!
public class OutputCache_NonAdmin : DonutOutputCacheAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
HttpContext.Current.Response.Cache.AddValidationCallback(NonAdmin, null);
base.OnActionExecuting(filterContext);
}
private void NonAdmin(HttpContext httpContext, object data, ref HttpValidationStatus httpValidationStatus)
{
httpValidationStatus = FormsAuthenticationService.IsLoggedIn("Admin")
? HttpValidationStatus.IgnoreThisRequest
: HttpValidationStatus.Valid;
}
}
How can I achieve no caching when a user logs in?
source
share