title: How can I update a session after an Ajax call?
body: <p>My application makes a lot of requests to an API controller. The problem I am running into is that my APIController has no access to the current session (which - it shouldn't). But since the calls are made via javascript after the page loads - I don't know how to tell my app to update the session. </p>
  
  <p>What is the accepted way to handle changes to session values after receiving updated data from an ajax call?</p>
  
  <p>Example:</p>
  
  <pre><code>public static class SessionManager
  {
      public static User CurrentUser
      {
          get
          {
              return (User)HttpContext.Current.Session["CurrentUser"];
          }
          set
          {
              HttpContext.Current.Session["CurrentUser"] = value;
          }
      }
  }
  
  public class SomeController : ApiController
  {
      public HttpResponseMessage DeleteSomething(SomeModel model)
      {
          // Do work
      }
  }
  </code></pre>
  
  <p><strong>then in the view</strong></p>
  
  <pre><code>$.ajax({
       type: 'DELETE',
       url: '{PATH TO API}',
       data: { the data },
       traditional: true,
       success: function (response) {
           // Now I need to update the user stored in the session
           // How do I do that?
       } else {
       }
  });
  </code></pre>