title: Asp.Net Core 2.0 RedirectToAction not working after post
body: <p>I am new to MVC.  Here is the gist of what I am doing on my View:</p>
  
  <p>Display Identity User with their assigned User Roles.</p>
  
  <p>Clone User Roles portion of page:</p>
  
  <p>Have a SelectList where the end-user can select some other Identity User.</p>
  
  <p>Display that selected user's current User Roles - I have this working in a Partial View.</p>
  
  <p>Have a Clone User button and onclick remove all User Roles for the currently displayed user and then add them to all the Roles that the selected user from the 
  SelectList is assigned to.</p>
  
  <p>I have the View working the way I want it to with one exception - after changing the user's Identity Roles (via clicking the Clone User link) the portion of my View does not refresh to show the new Roles.  In my ViewModel that would be UserRoles.  If I press CTRL+F5 to refresh then I see the newest Roles.</p>
  
  <p>Here is my ViewModel:</p>
  
  <pre><code>public ApplicationUser AppUser { get; set; }
  public TblEmployee Employee { get; set; }
  [Display(Name = "User Roles")]
  public List&lt;Tuple&lt;string, string&gt;&gt; UserRoles { get; set; }
  [Display(Name = "Available Roles")]
  public List&lt;Tuple&lt;string, string&gt;&gt; AllRoles { get; set; }
  [Display(Name = "Select Employee")]
  public List&lt;SelectListItem&gt; EmployeeList { get; set; }
  </code></pre>
  
  <p>I have a link on my page:</p>
  
  <pre><code>&lt;a id="uxCloneUserButton" class="hidden"&gt;
      &lt;i class="glyphicon glyphicon-duplicate"&gt;&lt;/i&gt;  &amp;nbsp;Clone User
  &lt;/a&gt;
  </code></pre>
  
  <p>And then in my script in my View I have the following:</p>
  
  <pre><code>$('#uxCloneUserButton').click(function () {
      var selectedId = $('#uxEmployeeSelect').val();
      var appUserId = $('#uxHiddenAppUserId').val();
      var url = '@Url.Action("CloneUser", "ApplicationUser")';
  
      //post id and username to controller action
      $.post(url, { id: appUserId, cloneUserId: selectedId }, function (data) {
      });
  });
  </code></pre>
  
  <p>I get to the Action on my Controller with the proper parameters and it is working fine.  In my Controller I have this:</p>
  
  <pre><code>[HttpPost]
  public async Task&lt;IActionResult&gt; CloneUser(string id, string cloneUserId)
  {   
      ApplicationUser currentUser = await _userManager.FindByIdAsync(id);
      ApplicationUser cloneUser = await _userManager.FindByIdAsync(cloneUserId);
      //Remove currentUser from all current roles
      var currentUserRoles = await _userManager.GetRolesAsync(currentUser);
      if (currentUserRoles.Count &gt; 0)
          await _userManager.RemoveFromRolesAsync(currentUser, currentUserRoles.ToArray());
      var cloneUserRoles = await _userManager.GetRolesAsync(cloneUser);
      if (cloneUserRoles.Count &gt; 0)
          await _userManager.AddToRolesAsync(currentUser, cloneUserRoles.ToArray());               
      return RedirectToAction(nameof(Details), new { id = id });            
  }
  </code></pre>
  
  <p>Your help is greatly appreciated.  I just need this portion of the page to refresh after the click and I am all set.</p>
  
  <h1>UPDATE</h1>
  
  <p>I was able to get it working, but my solution doesn't feel like a good one.</p>
  
  <p>I added a string to my ViewModel:</p>
  
  <pre><code>public string JSRedirectLocation { get; set; }
  </code></pre>
  
  <p>I set the property in my Details Action where I assign all of my VM properties:</p>
  
  <pre><code>//Redirect location
  model.JSRedirectLocation = "/ApplicationUser/Details/" + model.AppUser.Id;
  </code></pre>
  
  <p>I changed my JavaScript to redirect after post:</p>
  
  <pre><code>//post id and username to controller action
  $.post(url, { id: appUserId, cloneUserId: selectedId }, function (data) {
      window.location = '@Model.JSRedirectLocation';
  });
  </code></pre>
  
  <p>Can somebody tell me if I should be doing this some cleaner way, please?  This solution seems to me to be redundant and feels like a workaround.  Thanks.</p>