Gidon
Gidon

Reputation: 537

how to set httpheaders in asp.net mvc

I need to set http header for disabling ie (7-8) caching (it disturbs my ajax functionallity). I've tried inserting this code to the head of my site.master with no result -

 <META HTTP-EQUIV="Pragma"
CONTENT="no-cache"> <META
 HTTP-EQUIV="Expires" CONTENT="-1">

How and where can I set the HTTP headers? or do you have a better solution for the ie caching issue.

regards.

Upvotes: 1

Views: 507

Answers (1)

LukLed
LukLed

Reputation: 31842

Try:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]

This attribute, placed in controller class, disables caching. Since I don't need caching in my application, I placed it in my BaseController class:

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public abstract class BaseController : Controller
{

Here is nice description about OutputCacheAttribute: Improving Performance with Output Caching

Upvotes: 1

Related Questions