Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access denied in saving the web.config file 1

Status
Not open for further replies.

steve1rm

Programmer
Aug 26, 2006
255
GB
Hello

VS 2005

I am using the code below to get and save the connection string in the web.config file. However on the webConfig.Save() line it throws an error:

An error occurred loading a configuration file: Access to the path 'c:\inetpub\ is denied. (c:\inetpub\
I am not sure what this file is "oa48wsfg.tmp" and why I have access denied.

Code:
 Dim cnnString As String
'Get the current connection string
        cnnString = WebConfigurationManager.ConnectionStrings("serviceMasterConnectionString").ConnectionString()
        cnn.ConnectionString = cnnString

'Save a new connection string
        Dim WebConfig As Configuration
        WebConfig = WebConfigurationManager.OpenWebConfiguration("~")
        WebConfig.ConnectionStrings.ConnectionStrings("serviceMasterConnectionString").ConnectionString = "data source=steve01\ssd01; database=serviceMaster; user id=sa; pwd="
        WebConfig.Save()'Error on this line.

I have gone into the IIS and right click web.config and given read and write permissions. but still get the same error message.

Can anyone please help me with this problem.

Many thanks,

Steve
 
You may need to setup the ASPNET account to have read/write permissions.

Wait, you are code to modify the web.config file? If you need to randomly adjust something like your webconfig you want to reconsider your design. If you need the connection strings in a more "fluid" location, try a database, or a separate xml file.

-The answer to your problem may not be the answer to your question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top