Yoav
Yoav

Reputation: 3386

Ajax.actionLink returns the same result in IE

I'm trying to implement an Ajax.ActionLink in my MVC4 website and for some reason I keep getting the same result in IE (Firefox works fine).
I added this to the bottom of my _Layout.cshtml page:

@Scripts.Render("~/bundles/jquery")  
@Scripts.Render("~/bundles/jqueryval")

(before adding the jqueryval line i kept getting redirected)
this is my ajax call:

@{
    ViewBag.Title = "Test";
}
<h2>Test</h2>

@Ajax.ActionLink("Click to get a new guid", "GetGuid",
new AjaxOptions
{
    UpdateTargetId = "result",
    InsertionMode = InsertionMode.InsertAfter,
    HttpMethod = "GET"
})
<div id="result">
</div>

my controller action:

public ActionResult GetGuid()
{
    string guid = Guid.NewGuid().ToString();
    return PartialView("_guid", guid);
}

and the partial view:

@model String
<div>
@Model.ToString()
</div>

When tested in IE I keep getting the same result appended, but in Firefox it works fine.

Any way to make this code compatible with IE or am I doing something wrong?

Upvotes: 1

Views: 758

Answers (1)

Slicksim
Slicksim

Reputation: 7172

Have you tried setting the following in the document ready of the layout?

$.ajaxSetup({cache:false});

Si

Upvotes: 3

Related Questions