'How to use encrypted web.config in ASP.NET MVC project to get connection string?
I encrypted my web.config file but when I upload the web.config into server the website is not accessible any more.
First I create a key by typing this code in cmd:
aspnet_regiis -pc "MyKeys" -exp
Then I modify web.config like this:
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<configProtectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurationProvider,
System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</configProtectedData>
<connectionStrings>
<add name="sth" connectionString="Data Source=sth; Initial
Catalog=2888_AtiRayan; User ID=sth; Password=sth; Integrated
Security=False;"
providerName="System.Data.SQLClient"/>
</connectionStrings>
</configuration>
Last I run below code in cmd and web.cofig encrypted successfully.
aspnet_regiis -pef "connectionStrings" "/MyApplication" -prov "MyProvider"
How do I use or decrypt this file?
All I found is decrypting by coding in cmd like above, but I uploaded my source to server and I can't access it so what can I do?
How can I use connection string from this encrypted file which is uploaded to server?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
