title: MVC 3 - Ajax.BeginForm does a full post back
body: <p>In the following code, I'm using Ajax.BeginForm to post data to the action asynchronously.  The action gets called but the results are displayed to a new web page.  I'v looked at a ton of example.  This doesn't seem difficult. I've made the example extremely simple for a proof of concept (poc), but I'm still seeing a new page displayed.  </p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>  [HttpPost]
      [OutputCache(Location = OutputCacheLocation.None, NoStore = true)]
      public string TestAjax(UserViewModel viewModel)
      {
  
          return viewModel.UserName;
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@model BasicMvc3Example2.Models.UserViewModel
  
  @{
      ViewBag.Title = "Index2";
      Layout = null;//"~/Views/Shared/_Layout.cshtml";
  }
  
        &lt;script src="/BasicMvc3Example2/Scripts/jquery-1.4.4.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/BasicMvc3Example2/Scripts/jquery-ui.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/BasicMvc3Example2/Scripts/jquery.validate.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;script src="/BasicMvc3Example2/Scripts/jquery.validate.unobtrusive.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;h2&gt;Index2&lt;/h2&gt;
  
      &lt;script type="text/javascript"&gt;
          function PostFailure(){
              alert("Failure");
          }
  
          function PostSuccess(){
              alert("Success");
          }
  
          function PostOnComplete() {
              alert("Complete");
          }
      &lt;/script&gt;
  
      Page Rendered: @DateTime.Now.ToLongTimeString()
      @using (Ajax.BeginForm("TestAjax", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "textEntered", OnFailure = "PostFailure", OnSuccess = "PostSuccess", OnComplete = "PostOnComplete" }))
      {
          &lt;div&gt;
             @Html.LabelFor(m =&gt; m.UserName)
             @Html.TextBoxFor(m =&gt; m.UserName)
          &lt;/div&gt;
  
          &lt;div&gt;
             @Html.LabelFor(m =&gt; m.Password)
             @Html.TextBoxFor(m =&gt; m.Password)
          &lt;/div&gt;
  
          &lt;div&gt;
             @Html.LabelFor(m =&gt; m.EmailAddress)
             @Html.TextBoxFor(m =&gt; m.EmailAddress)
          &lt;/div&gt;
  
          &lt;input type="submit" id="submitForm" value="Submit Form" /&gt;
      }
  
      &lt;div id="textEntered"&gt;d&lt;/div&gt;
  </code></pre>