Any section in my web.config file that I want to encrypt I run this 开发者_开发问答command line util: aspnet_regiis -pe "anySection" -app "/SampleApplication"
It all works just fine until I try encrypt my connectionStrings sections
I define (and I cannot change this) my connectionStrings section like this:
<connectionStrings>
<add key="myKey" value="myValue"/>
</connectionStrings>
But the "standard" way of defining it is like this:
<connectionStrings>
<add name="myName" connectionString="...." providerName="..." />
</connectionStrings>
How when I run:
aspnet_regiis -pe "connectionStrings" -app "/SampleApplication"
It errors with "...Unrecognized attribute 'key'....". If I change the connection string section to be the standard way it works fine. But I CANNOT use this format.
Is there a way of doing this using the aspnet_regiis util? Doing it with code is not an option for me.
Also is there a way to run this untility without specifing the application (-app "/SampleApplication") instead giving the path to the web.config file?
thanks a million
The add element inside the connectionStrings element has a well-defined schema (see http://msdn.microsoft.com/en-us/library/htw9h4z3.aspx) and it is not the same element as the add element inside the appSettings element.
If you want to encrypt the appSettings section, and that would be the entire appSettings section, you can do this:
aspnet_regiis -pe "appSettings" -app "/SampleApplication" -prov "RsaProtectedConfigurationProvider"
It looks like you've copied and pasted an appSetting
<add key="myKey" value="myValue"/>
is invalid since key
and value
are not an attributes the connectionString
element expects.
You will have to use the "standard"
<add name="myName" connectionString="...." />
connectionStrings Element (ASP.NET Settings Schema)
I got a similar error when I did not run the command line as an administrator.
精彩评论