In webforms I would do something like this in the OnInit method, but where (and how) could I do the same type of thing using MVC?
Response.Cache.SetCacheability(HttpCacheability.NoCache)
In webforms I would do something like this in the OnInit method, but where (and how) could I do the same type of thing using MVC?
Response.Cache.SetCacheability(HttpCacheability.NoCache)
You can do the exact same thing in MVC too in the controller action (by writing the same line of code) or adding an attribute (which is preferred):
[OutputCache(Location=System.Web.UI.OutputCacheLocation.None)]
public ActionResult Index() {
// ...
}
Do you mean a non-MVC page in an MVC application, then the same way. If you mean a particular action corresponding to a view, then use the OutputCacheAttribute on the action or controller with Location = OutputCacheLocation.None
.