title: How to persist HttpContext.Current between projects in same solution?
body: <p>I'm new to the concepts of FormsAuthentication and am struggling with something.</p>
  
  <p>I have an MVC4 project, MyApp.Web, which has an AccountController with a Login method:</p>
  
  <pre><code>public ActionResult Login(LoginModel model, string returnUrl)
  {
      string siteName = ConfigurationManager.AppSettings["siteName"];
  
      if (ModelState.IsValid &amp;&amp; MembershipService.Login(model.UserName, model.Password, siteName))
      {
          return RedirectToAction("Main", "Home");
      }
  }
  </code></pre>
  
  <p>MembershipService is in another project (Class Library)</p>
  
  <pre><code>public bool Login(string username, string password, string site)
  {
  
      // ....
      // do the validation, set up my ClaimsPrincipal and create a FormsAuthenticationTicket,
      // which is stored in the Cookies collection
  
      // now, we can save the ClaimsPrincipal to the relevant place
      if (HttpContext.Current != null &amp;&amp; HttpContext.Current.User != null)
          HttpContext.Current.User = claimsPrincipal;
      else if (Thread.CurrentPrincipal != null)
          Thread.CurrentPrincipal = claimsPrincipal;   
  
      return success;
  }
  </code></pre>
  
  <p>That all seems to work perfectly, I am validated as necessary, the ClaimsPrincipal is created and stored.</p>
  
  <p>My issue is, when I am redirected, back in MyApp.Web, to HomeController and I put a breakpoint in the Main method, HttpContext.Current is not the same as the one I had in my Membership project; none of the values that I set up in the Login method have persisted.</p>
  
  <p>So, simply, how do I ensure that they are the same and setting values on HttpContext.Current in one project carry through to any other projects I may have in the same solution?</p>
  
  <p>Thanks</p>