Вопрос

I am using the OutputCache attribute to cache my home page content

[OutputCache(CacheProfile = "Default")]
public ActionResult Index()
{
     .....
}

I also have a custom global attribute set-up that checks each request for a valid browser type

GlobalFilters.Filters.Add(new BadBrowserAttribute());

The OnActionExecuting fires as needed during the first request, but not again until the cache expires.

I had thought the Order value of the attributes may help but it doesn't seem to have made any difference.

Is it possible to get my custom attribute to fire every time for cached content?

Это было полезно?

Решение

It's impossible for your action to fire everytime. When you use caching (as in your code), on subsequent request results will be returned from cache, so action won't be executed.

A workoround might be to implement custom caching inside your action filter. Something like this

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top