Ajax.BeginForm acting strangely after upgrading to

2019-09-10 06:54发布

问题:

I have been using Ajax.form in asp.net mvc2 just fine for months. I upgraded my application to MVC3 and .net 4 and now, when posting my ajax form I get a dialog from the browser trying to download the json result.

here is my form

    <%using (Ajax.BeginForm("MyAction", "MyController", new AjaxOptions { UpdateTargetId = "status" })) ....

here is the return statment in my controller

....
string result = "Update Successfull";
var jsonresult = result;
        return Json(jsonresult, JsonRequestBehavior.AllowGet);

does MVC3 handle ajax forms differently than mvc2?

回答1:

ASP.NET MVC 3 uses jquery instead of MSAjax. So you might need to include the jquery unobtrusive ajax script for this to work. You also might checkout this blog post.