473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

using different web.config for development and deployment

We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are using
the tableadapter and dataset designer, which uses settings from web.config,
besides, there are other settings in the web.config that need to be different
while developing/debugging. Any suggestions for managing this better?

Joel
Jul 26 '06 #1
6 2398
It wouldnt be terribly pretty, but could you do something like the
following?
(forgive syntax, i dont use the tableadapter/dataset things so dont know
their props/methods)

Public Module General
Public Const devServer As String = "test.mycompany.com"
Public Const prdServer As String = "www.mycompany.com"
End Module

Then in your page (or control) do something like:

Sub Page_Load(...) Handles Me.Load
Select Case Request.ServerVariables("SERVER_NAME")
Case General.devServer
myTableAdapter.ConnectionString =
howEverYouGetConfigConnString("ConnectionStringDev ")

Case General.prdServer
myTableAdapter.ConnectionString =
howEverYouGetConfigConnString("ConnectionStringPro d")

End Select
End Sub
"Joel H" <Jo***@discussions.microsoft.comwrote in message
news:35**********************************@microsof t.com...
We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are
using
the tableadapter and dataset designer, which uses settings from
web.config,
besides, there are other settings in the web.config that need to be
different
while developing/debugging. Any suggestions for managing this better?

Joel

Jul 26 '06 #2
The standard appSettings section has an optional "file=" attribute that lets
you handle this kind of situation quite nicely.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Joel H" wrote:
We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are using
the tableadapter and dataset designer, which uses settings from web.config,
besides, there are other settings in the web.config that need to be different
while developing/debugging. Any suggestions for managing this better?

Joel
Jul 26 '06 #3
Hi Joel,

I would suggest not publishing your web.config with your deployment. That's
probably the easiest and best solution because there's really little reason
to update web.config. If changes are required they should be made
explicitly.

If that's not possible then I would suggest Web Deployment Projects which
allows you to configure configuration section values to be changed on
compilation. You can put your configuration sections into seperate files
that the compiler will pick up when the project is precompiled to disk
before deployment. Also WDP can compile into a single assembly which is also
much better than deploying the entire mess of compiled files that hte stock
pre-compiler uses.

http://msdn.microsoft.com/asp.net/re...structure/wdp/

+++ Rick ---

--
Rick Strahl
West Wind Technologies
http://www.west-wind.com/weblog
http://www.west-wind.com/wwThreads/
"Joel H" <Jo***@discussions.microsoft.comwrote in message
news:35**********************************@microsof t.com...
We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are
using
the tableadapter and dataset designer, which uses settings from
web.config,
besides, there are other settings in the web.config that need to be
different
while developing/debugging. Any suggestions for managing this better?

Joel
Jul 26 '06 #4
"Joel H" <Jo***@discussions.microsoft.comwrote in message
news:35**********************************@microsof t.com...
Any suggestions for managing this better?
http://msdn.microsoft.com/asp.net/re...structure/wdp/
Jul 26 '06 #5
Uli
Hi,

here is the way I'm doing it.

Set a machine identity in the machine.config that says if it is a
development, stage or production server (e.g. d, s or p. It might be good to
add an "l" for local also).

for the Development-server
<add key="ApplEnv" value="d" />
Then you can put the connection strings for all environments into the
web.config

<add key="ConnectionString-l" value="server=(local);......."/>
<add key="ConnectionString-d" value="server=DEV-Server;......"/>
<add key="ConnectionString-s" value="server=STG_Server;....."/>
<add key="ConnectionString-p" value="server=PRD-Server;....."/>

In your code put something like:

private static string DbConnectionString
{
get
{
string strApplEnv = ConfigurationSettings.AppSettings["ApplEnv"];
string paramSuffix = strApplEnv.ToLower().Substring(0,1);
return ConfigurationSettings.AppSettings["ConnectionString-" +
paramSuffix] ;
}
This way you can use the web.config for all environments.

Regards,
Uli

--
Wer nicht fragt, stirbt dumm.
If you don''t ask, you''ll die as a dumba**.
"Joel H" wrote:
We have several settings in web.config that are different on the developer
side than the production side. Our website sourcecode is under sourcesafe
control, so before we code, we check out the web.config and change our
connection strings to point to development databases, and change
"debug=true". Before we deploy, we change everything back. We can't
dynamically select the proper connection string in code because we are using
the tableadapter and dataset designer, which uses settings from web.config,
besides, there are other settings in the web.config that need to be different
while developing/debugging. Any suggestions for managing this better?

Joel
Oct 31 '06 #6
"Uli" <Ul*@discussions.microsoft.comwrote in message
news:0D**********************************@microsof t.com...
here is the way I'm doing it.
Or, alternatively, use Web Deployment Projects and do it properly...
http://msdn.microsoft.com/vstudio/te...build/wdp.aspx
Oct 31 '06 #7

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

Similar topics

43
by: nospam | last post by:
I got three (3) files (1) Untitled.aspx (2) Untitled.aspx.1.cs (3) Untitled.aspx.2.cs These three files must be used together to make file #1, Untitled.aspx, page work via J.I.T. when the...
0
by: Jony Joe | last post by:
Dear All; I am now making a deployment package using the .net deployment setup project. It is a desktop application that its solution contains 7 projects that generate DLLs and EXEs...
3
by: Marek | last post by:
Hi there, my WinForm application has to be installed in "no-touch-deployment" mode, so users can run it from the web. I need to read application's .config file but it does not work in ...
4
by: Benne Smith | last post by:
In our company, i have three servers; 1) a development server (mine only - here i make daily changes and test my stuff) 2) a test server (for the users to test milestone builds - changes weekly)...
8
by: Graham | last post by:
I noticed a similar post awhile ago and in terms of my problem it wasnt a suitable answer so I will ask again. I have VS2005 running a on development machine in my office where I do all my...
4
by: James | last post by:
I have a VB windows forms application that accesses a Microsoft Access database that has been secured using user-level security. The application is being deployed using No-Touch deployment. The...
4
by: Peter | last post by:
Hello I created a dll assembly unsing the settings (only application settings). I read a lot a lot about the new settings concept, but I still don't understand it. The settings are in two...
0
by: Brian McCullough | last post by:
Hello, I have a Web Deployment Project (WDP) for my Web Site Project (WSP) (not a Web Application Project). I put an additional prodAppSettings.config file on my development machine and...
2
by: Fresno Bob | last post by:
I quite like to store variables in the web.config file. However it can make the web.config messy and make deployment fiddly. Is there any way of have multiple web.config files - one with the major...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.