MVC.Net, Ajax.BeginForm, jQuery and IE8

I am trying to use the "standard" MVC.Net unobtrusive JavaScript AJAX pattern as described here:

More specifically, the template might look like this:


@using (Ajax.BeginForm("action1", "controller1",
    new AjaxOptions()
        HttpMethod = "POST",
        OnSuccess = "successHandler",
    new { id = "formId" }

    @Html.TextBoxFor(m => m.ModelItem)
    <input type="submit" value="Go" />


I believe I created the required elements in the Web.Config along with what appears to be working jQuery code. The "action1" method on the controller is set to return a JsonResult, perhaps like this:

// In the CONTROLLER response (and with MODEL it doesn't matter here)

    public JsonResult action1(MyModel model)
        if (ModelState.IsValid)
            return Json(new { statusCode = 1 });

        return Json(new { statusCode = 0 });


This pattern works great when I'm using "modern" browsers; that is, the latest versions from three major suppliers. However, when I try to do anything with Internet Explorer 8 (and presumably before), I get a File Download - Security Warning dialog box. I believe this dialog comes up because the browser doesn't know how to handle the content type generated by JsonResult (application / json) and therefore prompts the user to save the return value. However, changing the content type in the JsonResult method, such as "text / plain" or "text / html", also does not work. Instead, IE8 redirects the browser window to display the original JSON sent back. None of these steps work for me.

I make sense that the problem is with the vertex, i.e. the "ajaxification" of the Ajax.BeginForm just doesn't happen in IE8, but I could be wrong and I don't know what to do about it anyway.

Any hints?



source to share

All Articles