1

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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried everything aspnet_regiis -pe "connectionStrings" -app "E:/Dropbox/NewTestAPI" -prov "RsaProtectedConfigurationProvider" says error -app parameter must start with forward slash. I tried aspnet_regiis -pe "connectionStrings" -app "/E:\Dropbox\NewTestAPI" -prov "RsaProtectedConfigurationProvider" it gives configruation file cannot be created for the requested Configuration object
1

You can run directly through the location

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

6 Comments

I tried as you said. It says ProConnection not found. Is the -app holds the name of the WEB API application ? I gave the application name but it says not found
the argument for -pe is the section name which should be "connectionStrings"
@ChrisTaylor it should not be the name of the connectionStrings?
@ChrisTaylor I tried aspnet_regiis -pe "connectionStrings" -app "/E:\Dropbox\NewTestAPI" -prov "RsaProtectedConfigurationProvider" It says "configruation file cannot be created for the requested Configuration object"
I tried giving the command different ways but I get the same error message configruation file cannot be created for the requested Configuration object , aspnet_regiis -pe "connectionStrings" -app "/E:\Dropbox\NewTestAPI" -prov "RsaProtectedConfigurationProvider" or giving the physical path of the website created in IIS as aspnet_regiis -pe "connectionStrings" -app "/E:\Dropbox\ABC\TestAPI" -prov "RsaProtectedConfigurationProvider" I even tried giving the Site ID as aspnet_regiis -pe "connectionStrings" -app "/E:\Dropbox\ABC\TestAPI" -site "3" -prov "RsaProtectedConfigurationProvider"
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.