When we publish the website, encryption web.config, this can effectively guarantee the database user and password security, the steps are as follows:
1. Add encryption Key
Executive: c:windowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pc "Hnlaw"-exp
where "Hnlaw" is the key name
2. Add Web.config node
Add between web.config:
Note: here Keycontainername= "Hnlaw" and Name= "Hnlaw" respectively indicate your key name;
3. Encryption Web.config
Add a batch file Enweb.bat to the site root directory, as follows:
The code is as follows:
@echo off
C:windowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pef "System.web/identity" "E:HS StudioDonet2Hnlawyer"-prov
"Hnlaw"
C:windowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pef "connectionstrings" "E:HS StudioDonet2Hnlawyer"-prov
"Hnlaw"
PAUSE
Register the path and the name above!
Success occurs after running!
4. Decryption
Also add a batch file Deweb.bat to the site root directory, as follows:
The code is as follows:
@echo off
C:windowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pef "System.web/identity" "E:HS StudioDonet2Hnlawyer"
C:windowsmicrosoft.netframeworkv2.0.50727aspnet_regiis-pdf "connectionstrings" "E:HS StudioDonet2Hnlawyer"
PAUSE
The last thing to note: Find the c:documents and Settingsall usersapplication Datamicrosoftcryptorsamachinekeys directory When you're done, and find the build
Key file (can be found by the time), give the Network service Read permission, or it will appear error message from the Provider:the RSA key container could
Not to be opened.
Cannot read
This may appear, if you do not have your own server, do not have permission to modify the MachineKeys directory, do not know there are other solutions, I hope you share the:)