Request performance using Html.Beginform versus jQuery AJAX

Asked

Viewed 88 times

1

There is some performance gain when using jQuery to perform ajax requests relative to the post using Html.Beginform?

@using (Html.BeginForm("Create", "Teste")
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        <div class="form-group">
           @Html.LabelFor(m => m.Nome, new { @class = "col-md-2 control-label" })
        <div class="col-md-10">
        @Html.TextBoxFor(m => m.Nome, new { @class = "form-control" })
        <span class="help-block">@Html.ValidationMessageFor(model => model.Nome, "", new { @class = "text-danger" })</span>
   }
   <div class="form-group">
      <div class="col-md-offset-2 col-md-10">
         <input type="submit" class="btn btn-default" value="Enviar" />
      </div>
   </div>

If it is better to do it via ajax request, have some sample code where it deals with Validationsummary and Validationmessagefor?

1 answer

1


The truth is that there is no relationship between the two practices, so to speak.

The Html.BeginForm() runs still on the server, it just helps - after all, it is a HTML Helper - creating the tags <form></form>.

Already jQuery, this runs on the client side, in the browser, well after the life cycle of the BeginForm() have finished.

  • My question is not about HTML.Beginform itself, but how the request is made.

  • This is set up in both ways. But both will by default make an HTTP POST Request. So in the end, they do exactly the same thing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.