trx
trx

Reputation: 2157

Encrypt the connection String in ASP.NET Web Config

I am trying to encrypt the connection string that is being given in the web.config file using aspnet_regiis. So I have the Connection String as

<connectionStrings>
 <add name="ProConnection" connectionString="Data Source=J;User Id=T;Password=C;pooling=true;min pool size=5;Max Pool Size=60" providerName="Oracle.DataAccess.Client"/>
</connectionStrings>

So I am trying to open the aspnet_regiis.exe as

aspnet_regiis -pe "ProConnection" -app "/NewTestAPI" -prov "RsaProtectedConfigurationProvider"

in the C:\Windows\Microsoft.NET\Framework\v4.0.30319 but I am not able able to open it. I tried even giving the Run as administrator but still nothig opens. Is it the same way doing it or I am I missing something. Any help is greatly appreciated

Upvotes: 1

Views: 5236

Answers (2)

thinkin you have this

    <configuration>
  <connectionStrings>
    <add name="SqlServices" connectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;" />
  </connectionStrings>
</configuration>

Open Command Prompt with Administrator privileges and look for net framework directory usually

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

After you're in net framework directory and you know your webconfig directory example "c:\DirectoryName\DirectoryProject" directory path, then enter the following to encrypt the ConnectionString:

ASPNET_REGIIS -pef "connectionStrings" "D:\DirectoryName\WebConfig"

Use Aspnet_regiis.exe tool with the –pef option and specify the application path as shown above.

Note: The parameter "connectionStrings" is case sensitive.

Upvotes: 2

Mostafiz
Mostafiz

Reputation: 7352

You can run directly through the location

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pe "ProConnection" -app "/NewTestAPI" -prov "RsaProtectedConfigurationProvider" 

Upvotes: 1

Related Questions