Azure Exception after scaling

System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.

I have recently scaled my application deployed in Azure for 2 instances. After scaling that I got the above exception when loading the application. After searching for hours I came across the solution for it.

What you have to do is add the following code snippet in your configuration.

  1. <system.identityModel>
  2.   <identityConfiguration>
  3.     <securityTokenHandlers>
  4.       <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler,  
  5.              System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  6.       <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler,
  7.              System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  8.     </securityTokenHandlers>
  9.   </identityConfiguration>
  10. </system.identityModel>

For more information visit here.

Happy Coding !!!!!!

Comments

Popular posts from this blog

Responsive Web Design

Affine Cipher in C#

Contract First Development in WCF 4.5