from test to production

E

ericvdb

Hi all,

how are you guys handling the deployment and settings from a test server to
a production server?
In particular, if I have a db connection in my web.config pointing to my
test db server, do i need to modify it manualy on the productionserver once
the site has been deployed?

I have the same question for sql reporting services, but i'll post that in
another forum.

Thanks in advance.
Eric
 
K

Ken Dopierala Jr.

Hi Eric,

I'm not sure if this is the best way to do this, here is how I'm currently
handling the connection string/which mail server/etc. solution in my apps.

Private Function GetDSN() As String
Dim strtest As String
strtest = Me.Server.MapPath("test.txt").ToLower
If (strtest.LastIndexOf("tempprojectsfolder") <> -1) Then
Return "production connection string"
Else
Return "dev connection string"
End If
End Function

The 'test.txt' file doesn't need to exist. I use the LastIndexOf to check
for a folder in the path that I know only exists in the developers'
environments. If it doesn't find it then I know I'm on the production
server and I return the correct string. You can also expand this to check
for QA or whatever else. Just make sure if you have multiple developers
that they stay uniform as far as their directory structure and you should be
good to go. I also use this to determine other servers like which SMTP
server to use and stuff. Good luck! Ken.
 
K

Ken Cox [Microsoft MVP]

Hi Eric,

Here's how we handled that one in our small group. We all used the same
web.config file but each put in a key to handle our local machines. By
detecting the machine name, we could pick up the correct connection string.
Here's the idea. Let us know if this helps?

Ken
Microsoft MVP [ASP.NET]
Toronto


Private Sub Page_Load _
(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim strConnection As String
Dim strSERVER_NAME As String = _
Replace(Context.Request.ServerVariables("SERVER_NAME"), ".", "_")
strConnection = ConfigurationSettings.AppSettings _
(strSERVER_NAME & "_db")
Label1.Text = strConnection
End Sub

web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

<appSettings>
<add key="localhost_db" value="connectionstringforlocalhost"/>
<add key="www_mydomain_com_db" value="connectionstringforproduction"/>
<add key="p4320_db" value="connectionstringformymachine"/>

</appSettings>
<system.web>
.....
 
M

Malik Asif Joyia

Hello
Yeah offcourse you need to modify to the online db server .
you will must change the web.config , and will modify your conection string.
other wise you will need to write some logic to check that if it is online
server then user this connection string Else use local connection string

Kind Regards
Malik Asif
 
S

Scott Allen

Another tip is to keep environment specific app settings in an
external file.

Web.config looks like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation defaultLanguage="c#" debug="false" />
</system.web>

<appSettings file="production.config"/>

</configuration>

And in production.config:

<appSettings>
<add key="ConnectionInfo"
value="server=foo;..." />
</appSettings>

You'd still need to modify web.config to change value like debug from
true to false, but at least production settings can live unchanged in
a file all thier own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top