I have edited the web.config for my SharePoint iis web application and added the following:
<add name="MyConnectionString" connectionString="Data Source=mysqlserver;network library=dbmssocn;Initial Catalog=mydb;User Id=myuser;Password=somepassword;" providerName="System.Data.SqlClient" />
From my web part, I can access the connection string like this:
string lcConnectionString = "";
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
if (rootWebConfig.ConnectionStrings.ConnectionStrings.Count > 0)
connString = rootWebConfig.ConnectionStrings.ConnectionStrings["MyConnectionString"];
if (connString != null)
lcConnectionString = connString.ConnectionString;
Now, I want to encrypt the connection string found in the web.config so I did this:
aspnet_regiis -pef "connectionStrings" "C:\inetpub\wwwroot\wss\VirtualDirectories\443"
This works and the appropriate information is encrypted in the web.config file.
I added the application pool account to have access to decrypt this information like this:
aspnet_regiis -pa "NetFrameworkConfigurationKey" "mydomain\myapppoolaccount"
Now, when I access the SharePoint site, I get the following error:
HTTP 500 Internal Server Error
I enabled verbose logging in Central Administration and used ULS viewer and found this in the log:
"Error=The RSA key container could not be opened."
At this point I am not sure how to proceed. Is there another account that needs to be assigned to have access using aspnet?
Since this is a test environment, I added the farm account to have access too but the error still persists.
Any help is appreciated...
Please check if identity impersonate is set to true in web.config file and windows authentication is enabled, if so, and it doesn’t work, try to pass “NT Authortity\Authenticated Users” as the account name to
check the result, you can refer to the following link for more information:
More information, how to encrypt configuration sections in asp.net:
TechNet Community Support
Microsoft is conducting an online survey to understand your opinion of the Msdn Web site. If you choose to participate, the online survey will be presented to you when you leave the Msdn Web site.
Would you like to participate?