title: Get user claims before any page loads on external ADFS login
body: <p>What I'm trying to do is accessing user claims which returns from ADFS login. ADFS returns username and with that username I have to run a query to another DB to get user information and store it. I don't really know where to do that and what the best practice is. I can access user claims in the view controller like:</p>
  
  <pre><code>public ActionResult Index()
  {
      var ctx = Request.GetOwinContext();
      ClaimsPrincipal user = ctx.Authentication.User;
      IEnumerable&lt;Claim&gt; claims = user.Claims;
      return View();
  }
  </code></pre>
  
  <p>But what I need to do is as I said access claims like in global.asax.cs or startup.cs to store user information before the application runs.</p>
  
  <p>This is my Startup.Auth.cs file:</p>
  
  <pre><code>public partial class Startup
  {
      private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
      private static string adfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
  
      public void ConfigureAuth(IAppBuilder app)
      {
          app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
  
          app.UseCookieAuthentication(
              new CookieAuthenticationOptions
              {
                  AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
              });
  
          app.UseWsFederationAuthentication(
              new WsFederationAuthenticationOptions
              {
                  Wtrealm = realm,
                  MetadataAddress = adfsMetadata
              });
      }
  }
  </code></pre>