Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - Prevent Cache on Ajax.ActionLinks

Is there anyway to disable the cache when using Ajax.ActionLink. Im having problems in IE whereby If I remove an item, which uses an ajax actionlink, it then reloads the partial view which the item is contained, and the item re-appears there (even tho it has been removed) On other browser's it works fine and as intended

   @Ajax.ActionLink("x", "RemoveItem", new { id = item.QuoteLineID, enquiryId = item.EnquiryID }, new AjaxOptions()
   {
       InsertionMode = InsertionMode.Replace,
       UpdateTargetId = "Summary"
   }, new { @class = "delete-link" })
like image 891
CallumVass Avatar asked Jan 27 '12 09:01

CallumVass


1 Answers

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

or append a random parameter to the request using the routeValues argument.

like image 97
Darin Dimitrov Avatar answered Oct 13 '22 01:10

Darin Dimitrov