title: How can i use RedirectToAction within $.ajax POST?
body: <p>I'm trying to redirect with the following method of the controller:</p>
  
  <pre><code>[HttpPost]
      public async Task&lt;IActionResult&gt; CreateSchedinaB([FromBody]ListAssociazioni listAss)
      {
          var userr = await _manager.GetUserAsync(User);
          var listSchedine = await _context.Schedine.ToListAsync();
  
          List&lt;Associazioni&gt; listAssocia = new List&lt;Associazioni&gt;();
          Schedine schedina = new Schedine();
  
          bool doppione = false;
  
          foreach (var item in listSchedine)
          {
              if (listAss.NomeS == item.Nome)
              {
                  doppione = true;
              }
          }
          if (doppione == false)
          {
              schedina.Nome = listAss.NomeS;
              schedina.KsProfile = userr.ProfileId;
              schedina.Id = _context.Schedine.Count() + 1;
              _context.Schedine.Add(schedina);
          }
          else
          {
              ViewData["Success"] = "Data was saved successfully.";
  
              return RedirectToAction("Index");
          }
          foreach (var item in listAss._listAssoc)
          {
              var giocata = _context.Giocate.Where(c =&gt; c.Id == item.KsGiocata).First();
              var partita = _context.Calendario.Where(c =&gt; c.Id == item.KsPartita).First();
  
              Associazioni tmp = new Associazioni { KsGiocataNavigation = giocata, KsPartitaNavigation = partita, KsSchedinaNavigation = schedina };
              _context.Associazioni.Add(tmp);
          }
          await _context.SaveChangesAsync();
          return RedirectToAction("Index");
      }
  </code></pre>
  
  <p>I don't call the method with an asp-action in the view but with in $.ajax post in this way:</p>
  
  <p>-VIEW:</p>
  
  <pre><code>`&lt;div class="form-group"&gt;
      &lt;label asp-for="schedine.Nome" class="col-md-2 control-label"&gt;&lt;/label&gt;
      &lt;div class="col-md-10"&gt;
          &lt;input id="nomeSchedina" asp-for="schedine.Nome" class="form-control" /&gt;
          &lt;span asp-validation-for="schedine.Nome" class="text-danger"&gt;&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;a class="btn btn-default" onclick="InviaServer()" &gt;CREA&lt;/a&gt;`
  </code></pre>
  
  <p>-JS:</p>
  
  <pre><code>function InviaServer() {
      var Nomes = $("#nomeSchedina").val();
      if (Nomes == "" || Nomes == null) {
          window.alert("Dai un nome alla tua schedina!");
          return;
      }
      var listadef = {"NomeS": Nomes, "_listAssoc": json};
      $.ajax({    // Send list to controller
          headers: {
              'Accept': 'application/json',
              'Content-Type': 'application/json'
          },
          url: "/Logged/CreateSchedinaB/",
          type: "POST",
          data: JSON.stringify(listadef),
          success: function (response) {
              console.log(response);
          }
      });
  }
  </code></pre>
  
  <p>CONTROLLER - INDEX</p>
  
  <pre><code>[HttpGet]
          public IActionResult Index()
          {
              return View();
          }
  </code></pre>
  
  <p>The problem is that the method does not redirect to the page but sends the page in the browser console ... why?</p>
  
  <p>Sorry my english ... I'm an "absolute beginner"</p>