ASP.Net MVC Unwanted Caching Issue

asp.net-mvccaching

I've got an issue with an ASP.Net MVC project in that on most of my edit screens if I make a change, save it then go back into my edit screen the new changes are not shown, if I then press F5 to refresh the page the changes are then shown. I'm guessing this is some sort of caching issue? I've never had this problem with WebForms, I assume the server does not cache ASPX pages as it knows they could be dynamic content.

Does anyone know what the deal with MVC is and caching? Also what would be the best way to stop caching from occurring on any of my dynamic pages (which is most of them, so I would happily turn it off for all pages), I would rather do this project side rather than IIS end if possible.

Thanks

Best Answer

Decorate your ActionResult with the OutputCache attribute (see this question):

[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")]
public ActionResult Edit(int id) { }