title: asp.net mvc ajax.BeginForm Redirecting
body: <p>I dont think i quite get the Ajax functions in mvc, because i get this wierd problem.</p>
  
  <p>I got the following code which makes my ajax call, it is placed in a partial view with a productList:</p>
  
  <pre><code>                &lt;% using(Ajax.BeginForm("AddToBasket", "Basket", 
                              new { productID = item.Id }, 
                              new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "Basket", OnSuccess = "productAdded(" + item.Id + ")" })) { %&gt;
                      &lt;input type="image" src="/Content/addToCart.png" /&gt;
                  &lt;% } %&gt;
  </code></pre>
  
  <p>I have a <code>&lt;div id="Basket"&gt;&lt;/div&gt;</code> on my masterpage</p>
  
  <p>And this method in BasketController, which returns a partial view that is found in Basket/BasketList.ascx:</p>
  
  <pre><code>        [HttpPost]
      public ActionResult AddToBasket(int productID)
      {
          // DO STUFF
  
          return PartialView("BasketList");
      }
  </code></pre>
  
  <p>When i am logged in using the default asp.net membership it all works fine, it updates the basket and it is all async, but when i am logged out and is clicking the addToCart, it redirects me to Basket/AddToBasket?productID=1, which is a partial view.</p>
  
  <p>Does anyone know why this happens?</p>
  
  <p>I have a similar problem with an ajax.actionlink</p>
  
  <pre><code>&lt;%= Ajax.ActionLink("Gem", "SaveBasket", "Basket", new AjaxOptions { HttpMethod = "Post" })%&gt;
  </code></pre>
  
  <p>where it says "The resource cannot be found." when it should fire, which is placed in the BasketController</p>
  
  <pre><code>[HttpPost]
  public void SaveBasket()
  {
      // DO STUFF
  }
  </code></pre>