4

I would like to avoid caching if the user is logged in with forms authentication in the admin group.

I have overridden the cache attribute and have applied it at the controller level. However, the method NonAdmin does not get called via the 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)
    {
        //-- METHOD DOES NOT GET CALLED!
        httpValidationStatus = FormsAuthenticationService.IsLoggedIn("Admin") 
            ? HttpValidationStatus.IgnoreThisRequest 
            : HttpValidationStatus.Valid;
    }
}

How can I achieve non-caching when the user is logged in?

Valamas
  • 24,169
  • 25
  • 107
  • 177
  • Did you found a solution for this? I'm having the same problem. – Jeroen Breuer Jul 15 '15 at 12:19
  • I have not. I only have a manual workaround where I created a page in the admin system to clear the cache. send me an email (see profile) if you want that code. – Valamas Jul 15 '15 at 21:27

0 Answers0