Wednesday, July 27, 2016

Setting Machine Key in ASP.NET Web.config

Setting Machine Key in web.config is important when you hosted your Application in Web Farm


Setting up Machine Key in Web farm is important because web farm servers need to share same machine-key for encryption/decryption, you will not have any way to know which machine/server will handle any particular request, so all Web farm servers have to have same key so that they can decrypt items that were encrypted by other machines/servers in the farm.

Setting Up the Machine Key Using IIS Manager

If you have access to the IIS management console for the server where Your Application is installed, it is the easiest way to set-up a machine key.
Start the management console and then select the web site. Open the machine key configuration:


The machine key control panel has the following settings:


Uncheck "Automatically generate at runtime" for both the validation key and the decryption key.
Click "Generate Keys" under "Actions" on the right side of the panel.
Click "Apply".

Setting Up the Machine Key Directly in the Web.config File

If you do not have access to the IIS management console, it is still possible to set-up a machine key for an application.
To do so, open the web.config file that is at the root of the web site. The machine key settings can be found or created under configuration/system.web:

<configuration>
  <system.web>
    <machineKey decryptionKey="Decryption key goes here,IsolateApps" 
                validationKey="Validation key goes here,IsolateApps" />
  </system.web>
</configuration>

 


 

No comments:

Post a Comment