?
Solved

Error when encrypting web.config database connection string

Posted on 2006-03-22
5
Medium Priority
?
260 Views
Last Modified: 2012-05-05
The code below is supposed to encrypt the database connection string in web.config, however, when run it throws an error.  Can anyone shed any light on why such an error would occur??

Dim path as string = "/netdump"
Dim config as configuration = WebConfigurationManager.OpenWebConfiguration(path)
Dim appSettings as configurationSection = config.getSection("connectionStrings")
If order then
      appSettings.sectionInformation.protectSection("DataProtectionConfigurationProvider")
Else
      appSettings.sectionInformation.UnprotectSection()
End If
config.Save()

- Error ----------------------------------------
Unable to save config to file 'c:\inetpub\wwwroot\netdump\web.config'.
Line 22:  config.Save()
0
Comment
Question by:Rouchie
  • 3
  • 2
5 Comments
 
LVL 26

Expert Comment

by:Rejojohny
ID: 16256144
where r u running this code from .. the same machine where the web server resides? is the file set as "read only" ...
0
 
LVL 25

Author Comment

by:Rouchie
ID: 16256256
The file isn't set as read only and it is on the same machine as the web server.  I've managed to work around the problem by setting the ASP.NET user account on the machine to have MODIFY access privileges to the file directly.  For some reason though, the FULL CONTROL box is ticked and also greyed out.  Not sure if this is an advisable way to proceed though from a security perspective.
0
 
LVL 26

Accepted Solution

by:
Rejojohny earned 2000 total points
ID: 16256295
once u have run the code to encrypt the connectionstring .. u can reset the permission of the file .. i assume u do not need this feature in the production environment .. right?
0
 
LVL 25

Author Comment

by:Rouchie
ID: 16256307
I guess not.  So if I encrypt locally on my development machine, and then copy web.config across to the server, the server will be able to read it okay?
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 16256337
i assume it should work .. unless the encrypt logic uses some machine specific details .. u could give it a try ... haven't tried it myself ..

Rejo
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question