Rami Alhamad
Rami Alhamad

Reputation: 281

Adding machineKey to machine.config

I would like to add the machineKey to my machine.config since I am working with programmatic encryption of web.config connection strings in a web farm scenario.

My question is, where do I place the machineKey in the machine.config file? There isn't one already there that I can replace, I suspect it's being autogenerated, so where should it be placed?

Upvotes: 21

Views: 34067

Answers (4)

peroija
peroija

Reputation: 1982

Just place it under <system.web>

If you need a key generated, use the process as shown in this SO post

Upvotes: 28

Claudinei Ferreira
Claudinei Ferreira

Reputation: 514

Get keys from sites can be a risk of security.

there's a simple way to do it, just use your IIS console

type inetMgr in Start

The IIS Console open. Click in Computer Keys

Computer Keys

The next step is set your keys. Select the appropriate, unflag the boxes to generate manually your keys, and finally click Generate Keys.

Screen where generate your keys

Finally, go in your Web.Config and above the set the tags.

Setting the keys in web.config

z

Upvotes: 3

Pankil Agrawal
Pankil Agrawal

Reputation: 101

Put Code in and generate machine key from this link

http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx

Upvotes: 1

Rup
Rup

Reputation: 34408

Inside <system.web>:

<system.web>
    <machineKey 
        validationKey="....." 
        decryptionKey="....." 
    />

which is at the bottom of the file in mine at least. I don't think the order of elements in system.web matters, as long as it's the top level directly beneath the system.web element.

Upvotes: 10

Related Questions