HTML.BEGINFORM POST GOING TO HTTPGET ACTION RATHER THAN HTTPPOST IN IE, FINE IN CHROME AND FIREFOX

Samuel Fernandes

Total Post:159

Points:1117
Posted by  Samuel Fernandes
 3704  View(s)
Ratings:
Rate this:

I have the following in my Razor view:

 @using (Html.BeginForm("Edit", "MyController", FormMethod.Post))

{

    <div class="grid_1">&nbsp;</div>

    <div id="ValSummary"> @Html.ValidationSummary(false)</div>

    @Html.EditorFor(x => x.Role, MVC.Shared.Views.EditorTemplates.KeyValuePairSelectList, new { SelectListOptions = Model.RoleSelectList })<br /><br />

    @Html.EditorFor(x => x.Trust, MVC.Shared.Views.EditorTemplates.KeyValuePairSelectList, new { SelectListOptions = Model.TrustSelectList.OrderBy(x => x.Text) })<br /><br />

    @Html.EditorFor(x => x.GmcCode)<br /><br />

    <div class="createbutton">

        <input id="btnGoBack" type="button" value="Back"/> 

        <input id="btnSubmit" type="button" value="Submit" />

    </div>

}

In my controller I have

[HttpGet]

public virtual ActionResult Edit(string id)

{

}

[HttpPost]

public virtual ActionResult Edit(ViewModel viewModel)

{

}

In Firefox and Chrome everything works fine but in IE when the form is submitted the HttpGet action is being fired rather than the HttpPost.

There are no clues in the call stack or from the IE developer tools console.

Anything obvious that I am missing?

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Html.BeginForm Post going to HttpGet action rather than HttpPost in IE, fine in Chrome and Firefox

    Hi samuel,

    Your Submit button should a real submit button with type="Submit"

    <input id="btnSubmit" type="submit" value="Submit" />

    to submit the form correctly in all browsers.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!