473,473 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Deploy without overwriting Web.Config

I develop my application on my dev server and then I deploy it to a
customer's production server. I store the db connection string in web.config
(is this best practice?). When I deploy I have to open the production
web.config and change the connection string to the correct one for
production. Now I want my customer to keep their sql server
username/password secret. They are unable/unwilling to change the web.config
each time I make an update to the app. How can I deploy my app without
having to access their web.config (each time I deploy it overwrites
web.config). There must be a way a dev can make an asp.net app and deploy it
it to a server without always knowing and having to change the connection
string. Thanks for any ideas!

Jan 17 '07 #1
4 7972
"dev648237923" <de**********@noemail.noemailwrote in message
news:Oj**************@TK2MSFTNGP04.phx.gbl...
>I develop my application on my dev server and then I deploy it to a
customer's production server. I store the db connection string in
web.config (is this best practice?). When I deploy I have to open the
production web.config and change the connection string to the correct one
for production. Now I want my customer to keep their sql server
username/password secret. They are unable/unwilling to change the
web.config each time I make an update to the app. How can I deploy my app
without having to access their web.config (each time I deploy it overwrites
web.config). There must be a way a dev can make an asp.net app and deploy
it it to a server without always knowing and having to change the
connection string. Thanks for any ideas!
http://msdn2.microsoft.com/en-us/asp.net/aa336619.aspx
Jan 17 '07 #2
Hi,

Every config section has an optional attribute named "configSource" to
point to an external file. Therefore you could break down your web.config
into several files and update them accoringly:

web.config:

...
<configuration>
<appSettings/>
<connectionStrings configSource="connectionStrings.config"/>
<system.web>
...

connectionStrings.config:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="..."
providerName="System.Data.SqlClient" />
</connectionStrings>
For more information:

======================
#General Attributes Inherited by Section Elements
http://msdn2.microsoft.com/en-us/library/ms228167.aspx

configSource
Optional String attribute.

Specifies the name of the include file in which the associated
configuration section is defined, if such a file exists.
======================

Also as Mark suggested, Web Deployment Project add-on could help you do the
deploy and merging automatically.
Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 18 '07 #3
Hi --

The problem I see with using a connectionStrings.config file is that it
appears that that file must reside in the app's dir or a subdir of it.
Whenever I redeploy the app that dir and its subdirs are deleted so I am
back to the same problem. Is there a way to have connectionStrings.config in
say c:\inetpub\securedir\connectionStrings.config and then have my app's
web.cofig reference that?
Thank you.
"Walter Wang [MSFT]" <wa****@online.microsoft.comwrote in message
news:52**************@TK2MSFTNGHUB02.phx.gbl...
Hi,

Every config section has an optional attribute named "configSource" to
point to an external file. Therefore you could break down your web.config
into several files and update them accoringly:

web.config:

..
<configuration>
<appSettings/>
<connectionStrings configSource="connectionStrings.config"/>
<system.web>
..

connectionStrings.config:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="..."
providerName="System.Data.SqlClient" />
</connectionStrings>
For more information:

======================
#General Attributes Inherited by Section Elements
http://msdn2.microsoft.com/en-us/library/ms228167.aspx

configSource
Optional String attribute.

Specifies the name of the include file in which the associated
configuration section is defined, if such a file exists.
======================

Also as Mark suggested, Web Deployment Project add-on could help you do
the
deploy and merging automatically.
Hope this helps.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 22 '07 #4
Hi,

Yes unfortunately the configSource attribute must be a relative physical
path. Both the default publishing tool and the Web Deployment Project
add-on will first delete the target directory before deploying, therefore
it's impossible to prevent some file in the target directory from being
updated.

As a workaround, I suggest:

1) first publish (either the default publish tool or WDP) to a temporary
place
2) use some script to backup the connectionStrings.config from the target
directory
3) delete all files in the target directory
4) move the files from the temporary directory to the target directory
5) restore the connectionStrings.config back to the target directory

Hope this helps.

Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wilson Ricardo Passos Oliveira | last post by:
Hi fellows, I have two simple questions regarding the Framework's deploy and the Setup and Deploy Projects: 1. As I've read in another posts and newsgroups (and as I can imagine), VS.NET...
0
by: mqsash | last post by:
Hi Problem : Unable to deploy an assembly in IE, as a cab file. (Works fine when deployed as a dll ) Description : I have created a assembly (dll with no user interface)in C# which I deploy in...
2
by: mqsash | last post by:
Hi Problem : Unable to deploy an assembly in IE, as a cab file. (Works fine when deployed as a dll ) Description : I have created a assembly (.dll) in C# which I deploy in IE. The dll name is...
1
by: evolve | last post by:
I'd like to deploy my website as an msi (which I do currently using the 'deployment project') but without the web.config file (I want the admin to put their own one in later) or with more...
2
by: John Spiegel | last post by:
Hi all, I'm attempting to deploy a pretty simple web service to a shared web server that was built w/ Visual Studio. According to MSDN, I should be able to just copy the asmx and bin folder (w/...
4
by: Andy Fish | last post by:
Hi, when I want to upgrade my asp.net web app on the deployment server, my process is basically this: 1. stop the web site in iis manager 2. in explorer, rename the web root directory from,...
0
by: jthomas | last post by:
Publishing with VisStudio2005 a C# windows/forms app via our IIS server. For one app, installing works fine. For another app, the <appname>.exe.config.deploy file is missing. The web admin logs...
0
by: jonathonmc | last post by:
I have a winform app written in C# which accesses a web service using a dynamic URL (configured in the app.config). When I deploy this app via ClickOnce it builds the app.config into the manifest and...
0
by: stephen | last post by:
Hi, I am using Click Once Deploy to deploy an application.(this application has an .exe, .config, .xml files) and after deployment to a location, I checked for the files and all the files are...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.