title: How to set the NameClaimType in an ASP.Net MVC 5 site?
body: <p>I've created an ASP.Net MVC 5 site using Microsoft's "On-Premises" Organization Account Authentication mechanism.  This is ultimately configured to point to my companies ADFS infrastructure.  I'm getting back all the configured claims.  However, at runtime, the ClaimsIdentity.Name is blank.  This is because the ClaimsIdentity.NameClaimType, by default, appears to be:</p>
  
  <pre><code>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
  </code></pre>
  
  <p>However, I want the ClaimsIdentity.Name to me mapped to:</p>
  
  <pre><code>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier 
  </code></pre>
  
  <p>According to <a href="http://msdn.microsoft.com/en-us/library/hh568636%28v=vs.110%29.aspx" rel="nofollow">Microsoft Docs</a>, the place to set this in web.config is within the Add element of the securityTokenHandlers element:</p>
  
  <pre><code>&lt;system.identityModel&gt;
    &lt;identityConfiguration&gt;
      &lt;securityTokenHandlers&gt;
        &lt;add&gt;
          &lt;samlSecurityTokenRequirement&gt;
            &lt;nameClaimType value=xs:string&gt;
            &lt;/nameClaimType&gt;
          &lt;/samlSecurityTokenRequirement&gt;
        &lt;/add&gt;
      &lt;/securityTokenHandlers&gt;
    &lt;/identityConfiguration&gt;
  &lt;/system.identityModel&gt;
  </code></pre>
  
  <p>In my ASP.Net MVC 5 web.config, the only thing that looks applicable, and passes intellisense checks ends up looking like this:</p>
  
  <pre><code>&lt;system.identityModel&gt;
    &lt;identityConfiguration&gt;
      &lt;securityTokenHandlers&gt;
        &lt;add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" &gt;
          &lt;samlSecurityTokenRequirement&gt;
            &lt;nameClaimType value="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"/&gt;
          &lt;/samlSecurityTokenRequirement&gt;
         &lt;/add&gt;
        &lt;remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
      &lt;/securityTokenHandlers&gt;
    &lt;/identityConfiguration&gt;
  &lt;/system.identityModel&gt;
  </code></pre>
  
  <p>However, this appears to have no effect.  My MVC app still reports a blank ClaimsIdentity.Name field and the ClaimsIdentity.NameClaimType continues to be:</p>
  
  <pre><code>http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name
  </code></pre>
  
  <p>What should my Web.Config look like to map my existing claim into the ClaimsIdentity.Name field?</p>