Ajax BeginForm posting to an action that returns json, IE tries to download it

Posted by ryanrdl on Stack Overflow See other posts from Stack Overflow or by ryanrdl
Published on 2010-05-12T13:39:30Z Indexed on 2010/05/12 13:44 UTC
Read the original article Hit count: 226

Here is the code I am using to setup the form:

        <% using (Ajax.BeginForm("SaveCroppedPhoto", new { Id = Model.memberId.GetValueOrDefault() }, new AjaxOptions
                                                                {
                                                                    OnBegin = "ProfileOnBegin",
                                                                    OnComplete = "ProfileOnComplete",
                                                                    OnFailure = "ProfileOnFailure",
                                                                    OnSuccess = "ProfileOnSuccess"
                                                                }, new { id = "cropPhotoForm" })) {%>

My action result returns a json result as follow:

 return Json(new { success });

In IE8 when the action returns, it tries to download the result. The content type coming back is application/json. Anyone have any idea how to stop IE from trying to download the result?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about JSON