StrataFrame Forum

deploying to production server

http://forum.strataframe.net/Topic6368.aspx

By Keith Chisarik - 1/29/2007

Is there a way I can deploy my web app to a new SQL Server without having to recompile Global.asax with the new IP?



Can I code it to read web.config or some other easier way, so I don't have to recompile or maintain two sets of compiled code, one for my test server and one for production and one for my test server.
By Keith Chisarik - 1/29/2007

Actually what would be nice os if the code was smart enough to know if it was running an server A or server B and execute the correct DataLayer.DataSources.Add command against the correct SQL Server.



Any idea how to accomplish this?



Can I write some code to query the server name or other identifier to evaluate against?

I am sure you can I just don't know how.
By Trent L. Taylor - 1/29/2007

All of this is entirely up to you as to how you would like to pull the connection string.  Since the connection has to be manually specified anyway, it is really easy to have it pull from a config file or some other file.  You can also place a test to determine which server you are on.  If you host names will be different then you could just use the host name and test on that within the global.asax when defining the connection string.

For example, the following code would look to see if the subdomain was different and create a connection based on that:

Dim lcHost As String = Request.Url.Host
Dim lcSubDomain As String = lcHost.Split(New Char() {"."c})(0)
       
'-- Set the session type
If lcSubDomain.Equals("www", StringComparison.OrdinalIgnoreCase) Then
    DataBasics.DataSources.Add(New MicroFour.StrataFrame.Data.SqlDataSourceItem("", "connectionstring1"))
ElseIf lcSubDomain.Equals("support", StringComparison.OrdinalIgnoreCase) Then
    DataBasics.DataSources.Add(New MicroFour.StrataFrame.Data.SqlDataSourceItem("", "connectionstring2"))
End If
By Keith Chisarik - 1/29/2007

Exactly what I wanted. Thanks.
By Trent L. Taylor - 1/29/2007

Great! BigGrin