title: How to get and decrypt the authenticatin cookie in a Web API MessageHandler
body: <p>I want to write a MessageHandler which extracts the authentication cookie from a HttpRequestMessage and decrypts it in odrer to get the username of the authenticated user. I could manage to get hold of the cookie but then I'm got stuck. I know there exists the FormsAuthentication.Decrypt() method but I don't know to use it here. </p>
  
  <pre><code>public class FormsAuthenticationHandler : DelegatingHandler
  {
      protected override async Task&lt;HttpResponseMessage&gt; SendAsync(
          HttpRequestMessage request, CancellationToken cancellationToken)
      {
          var formsCookieName = FormsAuthentication.FormsCookieName;
          var authCookie = request.Headers.GetCookies(formsCookieName).FirstOrDefault();
          if (authCookie != null)
          {
              string username = ???
  
              // further processing
          }
  
          var response = await base.SendAsync(request, cancellationToken);
          return response;
      }
  }
  </code></pre>