Reputation: 13
I'm new to MVC so I've been struggling a little bit... I have this URL.Action:
<a data-toggle="modal" data-target="#modal" href="@Url.Action("Edit", "ControllerName", new { id=item.id })"></a>
It is opening the view for "Edit" in a Modal, using bootstrap. The controller is like this:
// GET
[HttpGet]
public ActionResult Edit(int id = 0)
{
mv= bll.Details(id);
if (mv == null)
{
return HttpNotFound();
}
method(mv);
return PartialView(mv);
}
// POST:
[HttpPost]
public ActionResult Edit(TYPE pMv)
{
if (ModelState.IsValid)
{
bll.Edit(pMv);
return RedirectToAction("Index");
}
return PartialView(pMv);
}
So I click the link, it opens the modal with the view, I change the data, it saves in the Database, and everything is OK. The problem is with Internet Explorer: if I click again the link to Edit this Item, it opens the view in the model, but without passing through the controller's GET ActionResult, what causes the view to show the previous information, without the changes that I've made.
I can do this to every item, and they will all show they own information (not from the previous item), but without updating the changes that I've made. If I access the view using it's URL (//localhost:5528/MV/Edit/49), then the information gets updated.
Any idea why this is happening?
Upvotes: 0
Views: 64
Reputation: 7172
From your comments and for the benefit of others, IE is much more aggressive in it's caching, I personally suspect that is to try and bluff it's way as being as fast as chrome/firefox :)
You can diagnose this by looking in the network/profile tab or iis logs to see if the request is getting a 304 (Content not changed) response.
To fix the issue, just turn of caching for ajax calls by using this in either your _layout, or in each view that needs a fresh reload each time
$.ajaxSetup({cache:false});
Hope this helps others
Upvotes: 1