title: ASP MVC5 Partial view authentification redirection
body: <p>I'm quite new with ASP so be tolerant :)</p>
  
  <p>I've got a view with a search form in it. </p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;div id="search-form" class="row search-form"&gt;
      @using(Ajax.BeginForm("Search",
      "Home",
      new AjaxOptions
      {
          UpdateTargetId = "result",
          InsertionMode = InsertionMode.Replace,
          LoadingElementId = "ajax_loader"
      },
      new { @class = "form-horizontal col-sm-offset-3 col-sm-6" }
      ))
      {
          &lt;div class="form-group"&gt;
              &lt;div class="col-sm-10"&gt;
                  @{string query = string.Empty;}
                  @Html.EditorFor(x =&gt; query, new { htmlAttributes = new { @class = "form-control" } })
              &lt;/div&gt;
              &lt;input id="submitbtn" type="submit" value="Search" class="btn btn-primary col-sm-2" /&gt;
          &lt;/div&gt;
      }
  &lt;/div&gt;
  
  &lt;div id="ajax_loader" style="display:none"&gt;
      &lt;img src="~/Content/Images/ajax_loader.gif" alt="Ajax Loader" /&gt;
  &lt;/div&gt;
  &lt;div id="result"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[AllowAnonymous]
  public ActionResult Index()
  {
     ViewBag.Title = "serach form";
     return View();
  }
  
  public async Task&lt;ActionResult&gt; Search(string query)
  {
     WinesApiController winesCtrl = new WinesApiController();
     var listOfWines = await winesCtrl.Get(query);
     return PartialView("_WineResult", listOfWines);
  }
  </code></pre>
  
  <p>The <code>Search</code> method in my controller returns a PartialView. When I decorate all the methodsin the controller with the <code>[AllowAnonymous]</code> attribute, everything works very well. But what I would like it to display the form for anybody, but as long as you click on the search button, you need to be logged in. So I deleted all the AllowAnonymous attributes but on the Index method (the one which render my View). Now, the result of my call is not shown anymore (which is quite ok) but I am not redirected to the login view. </p>
  
  <p>My question is then, why the call to the partial view does not redirect me to the login view ? I guess that authentification is performed because I cannot see the results of the submit action, but why am I not redirected ?</p>