Request.IsAjaxRequest returns false on POST

My question is similar to this one and I have a similar problem, but the big difference is that I use Ajax helper methods ( Ajax.ActionLinkand Ajax.BeginForm) instead of handling AJAX with jQuery.

Request.IsAjaxRequest() returns true for the Edit method that accepts the HTTP GET, but false for the Edit method that accepts the http POST.

The GET request comes from a link generated by:

<%=Ajax.ActionLink(item.Name, "Edit", "Device",
     new { id = item.ID },
     new AjaxOptions { HttpMethod= "GET", UpdateTargetId = "ModalDialog" },
     new { name = item.Name })%>

The POST request comes from the form generated by this code:

<% using (Ajax.BeginForm("Edit", "Device", new { id = Model.ID }, new AjaxOptions { OnComplete = "CloseDialog" }))
{ %>
    <fieldset>
         <h4>
            <label for="Name">Name</label>
        </h4>
        <%= Html.TextBox("Name", null, new { @class = "required" })%>

        <h4>
            <input type="checkbox" id="IsActive" name="IsActive" <% if (Model.IsActive)%> <%=Html.Encode("checked=''")%> />
            <label for="IsActive">Unit Is Active</label>
        </h4>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
<% } %>

Is this by design, I am doing something wrong and how to fix it?

+2
source share
2 answers

. : AjaxOptions "CloseDialog" OnComplete. ? , MvcAjax script , .

+2

, . Firebug Firefox NET. XHR aSync.

0

All Articles