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?

4

0 回答 0