Hi there,
We are in the process of implementing Membership and Role Management and
have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the
Application["connection_string"] to the relevant ConnectionString from the
web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the
connectionStringName properties in the web.config for
AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings
issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the
connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards,
Larry. 7 9251
Interesting question! There could be several approaches to this, the simplest
of which would be to simply have a web.config file containing the correct
element values for the particular deployment scenario, of course.
However, if you look here: http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at
application startup (say, in Application_Start handler in Global.asax)
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Larry Neylon" wrote:
Hi there,
We are in the process of implementing Membership and Role Management and
have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the
Application["connection_string"] to the relevant ConnectionString from the
web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the
connectionStringName properties in the web.config for
AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings
issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the
connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards,
Larry.
google for "Web Deployment Projects" - a MS add in for VS.
They allow you based on build configuration to change the connection string
section in web.config.
-----
Dominick Baier ( http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications ( http://www.microsoft.com/mspress/books/9989.asp)
Interesting question! There could be several approaches to this, the
simplest of which would be to simply have a web.config file containing
the correct element values for the particular deployment scenario, of
course.
However, if you look here:
http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and
saved at application startup (say, in Application_Start handler in
Global.asax) Peter
"Larry Neylon" wrote:
>Hi there,
We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the Application["connection_string"] to the relevant ConnectionString from the web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the connectionStringName properties in the web.config for AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards, Larry.
Thanks for that Peter,
One question, which i can't answer myself as I'm not in the office.
Is the web.config updatable from the Application_Start ? i.e. can I have a
configuration string called "default", which I update in the
Application_Start to the value I need based upon environment, and then have
all the other references like AspNetSqlMembershipProvider point to "default"
?
Many thanks,
Larry.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:6B**********************************@microsof t.com...
Interesting question! There could be several approaches to this, the
simplest
of which would be to simply have a web.config file containing the correct
element values for the particular deployment scenario, of course.
However, if you look here:
http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at
application startup (say, in Application_Start handler in Global.asax)
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Larry Neylon" wrote:
>Hi there,
We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the Application["connection_string"] to the relevant ConnectionString from the web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the connectionStringName properties in the web.config for AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards, Larry.
While this website acutally is using the wrong name for configuration and imports the wrong library, if you substitute:
Imports System.Configuration
with
Imports System.Web.Configuration
And substitute
ConfigurationMananger
with
WebConfigurationManager
it shows you how to do just what you are talking about : http://www.ondotnet.com/pub/a/dotnet...onnstring.html
HTH
S
"Larry Neylon" <ld********@ntlworld.comwrote in message news:0e***************@newsfe4-gui.ntli.net...
Thanks for that Peter,
One question, which i can't answer myself as I'm not in the office.
Is the web.config updatable from the Application_Start ? i.e. can I have a
configuration string called "default", which I update in the
Application_Start to the value I need based upon environment, and then have
all the other references like AspNetSqlMembershipProvider point to "default"
?
Many thanks,
Larry.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:6B**********************************@microsof t.com...
>Interesting question! There could be several approaches to this, the simplest of which would be to simply have a web.config file containing the correct element values for the particular deployment scenario, of course.
However, if you look here:
http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at application startup (say, in Application_Start handler in Global.asax) Peter
-- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net
"Larry Neylon" wrote:
>>Hi there,
We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the Application["connection_string"] to the relevant ConnectionString from the web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the connectionStringName properties in the web.config for AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards, Larry.
Larry,
Under ASP.NET 2.0, the new ConfigurationManager class has methods that allow
you to read, modify and save most any kind of configuration data. All you
would need to do in Application_Start is to get the metadata you need
(hostname, whatever) to determine "what environment" this is, modify the
web.config appropriately, including saving a special key so it doesn't keep
doing it over and over again, and you can get the results you want.
I'd still be more inclined to use an MSBuild or other deployment arrangement
however, rather than attempting to change this kind of stuff on the fly at
runtime.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Larry Neylon" wrote:
Thanks for that Peter,
One question, which i can't answer myself as I'm not in the office.
Is the web.config updatable from the Application_Start ? i.e. can I have a
configuration string called "default", which I update in the
Application_Start to the value I need based upon environment, and then have
all the other references like AspNetSqlMembershipProvider point to "default"
?
Many thanks,
Larry.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:6B**********************************@microsof t.com...
Interesting question! There could be several approaches to this, the
simplest
of which would be to simply have a web.config file containing the correct
element values for the particular deployment scenario, of course.
However, if you look here: http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at
application startup (say, in Application_Start handler in Global.asax)
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Larry Neylon" wrote:
Hi there,
We are in the process of implementing Membership and Role Management and
have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the
Application["connection_string"] to the relevant ConnectionString from
the
web.config based upon the domain (so we can handle dev/test/live, etc).
The problem we have is that we can't see how to dynamically set the
connectionStringName properties in the web.config for
AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections
strings
issues than working out the correct one on app startup ?
b) If what we are doing isn't insane, how can you dynamically set the
connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards,
Larry.
In addition - changing the web.config at runtime causes an app domain recycle
and you may loose session or cache data...
-----
Dominick Baier ( http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications ( http://www.microsoft.com/mspress/books/9989.asp)
Larry,
Under ASP.NET 2.0, the new ConfigurationManager class has methods that
allow
you to read, modify and save most any kind of configuration data. All
you
would need to do in Application_Start is to get the metadata you need
(hostname, whatever) to determine "what environment" this is, modify
the
web.config appropriately, including saving a special key so it doesn't
keep
doing it over and over again, and you can get the results you want.
I'd still be more inclined to use an MSBuild or other deployment
arrangement
however, rather than attempting to change this kind of stuff on the
fly at
runtime.
Peter
"Larry Neylon" wrote:
>Thanks for that Peter,
One question, which i can't answer myself as I'm not in the office.
Is the web.config updatable from the Application_Start ? i.e. can I have a configuration string called "default", which I update in the Application_Start to the value I need based upon environment, and then have all the other references like AspNetSqlMembershipProvider point to "default" ?
Many thanks, Larry. "Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in message news:6B**********************************@microsof t.com...
>>Interesting question! There could be several approaches to this, the simplest of which would be to simply have a web.config file containing the correct element values for the particular deployment scenario, of course. However, if you look here:
http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at application startup (say, in Application_Start handler in Global.asax) Peter
-- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net "Larry Neylon" wrote:
Hi there,
We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the Application["connection_string"] to the relevant ConnectionString from the web.config based upon the domain (so we can handle dev/test/live, etc). The problem we have is that we can't see how to dynamically set the connectionStringName properties in the web.config for AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings issues than working out the correct one on app startup ? b) If what we are doing isn't insane, how can you dynamically set the connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards, Larry.
Exactly. But if he coded it correctly, it would only happen the one time that
he modifies his web.config, hence the suggestion to have some sort of special
"flag" to prevent it from happening over and over.
Not to be pedantic, but you don't "loose" Session or Cache data. Your pants
may be "loose", which could then cause you to "lose" them. :-)
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Dominick Baier" wrote:
In addition - changing the web.config at runtime causes an app domain recycle
and you may loose session or cache data...
-----
Dominick Baier (http://www.leastprivilege.com)
Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)
Larry,
Under ASP.NET 2.0, the new ConfigurationManager class has methods that
allow
you to read, modify and save most any kind of configuration data. All
you
would need to do in Application_Start is to get the metadata you need
(hostname, whatever) to determine "what environment" this is, modify
the
web.config appropriately, including saving a special key so it doesn't
keep
doing it over and over again, and you can get the results you want.
I'd still be more inclined to use an MSBuild or other deployment
arrangement
however, rather than attempting to change this kind of stuff on the
fly at
runtime.
Peter
"Larry Neylon" wrote:
Thanks for that Peter,
One question, which i can't answer myself as I'm not in the office.
Is the web.config updatable from the Application_Start ? i.e. can I
have a configuration string called "default", which I update in the
Application_Start to the value I need based upon environment, and
then have all the other references like AspNetSqlMembershipProvider
point to "default" ?
Many thanks,
Larry.
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote
in message news:6B**********************************@microsof t.com...
Interesting question! There could be several approaches to this, the simplest of which would be to simply have a web.config file containing the correct element values for the particular deployment scenario, of course. However, if you look here:
http://msdn2.microsoft.com/en-us/library/ms178411.aspx
you may get some ideas on how this can be dynamically altered and saved at application startup (say, in Application_Start handler in Global.asax) Peter
-- Site: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com Short urls & more: http://ittyurl.net "Larry Neylon" wrote:
Hi there,
We are in the process of implementing Membership and Role Management and have a problem with the connection strings in our web.config.
We currently have a system that on Application_Start set the Application["connection_string"] to the relevant ConnectionString from the web.config based upon the domain (so we can handle dev/test/live, etc). The problem we have is that we can't see how to dynamically set the connectionStringName properties in the web.config for AspNetSqlMembershipProvider, AspNetSqlRoleProvider, etc.
My questions are:
a) Is there a better way to handle the multiple sites / connections strings issues than working out the correct one on app startup ? b) If what we are doing isn't insane, how can you dynamically set the connectionStringName for the Membership and Roles stuff ?
Any help or advice would be much appreciated.
Regards, Larry.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Conway |
last post by:
I have no idea what is going on. I have a Login screen where someone types
in their login information and this populates a datagrid based off of the
login. Works great in debug and test through...
|
by: Tim Nelson |
last post by:
I am building a data bound application for SQL server which all the
forms I use sqlconnections generated by VS. I want to have a login form
that changes the connection depending upon login...
|
by: Samridhi Kumar Shukla |
last post by:
I am facing technical difficulti in using server connection control because
we cannot change the path once fixed ..
one way is to edit the code of the form generated code but though it allow
to...
|
by: Jon Davis |
last post by:
I like the drag-and-drop accessibility of dragging a table to a Web Forms
designer and seeing a SqlDataAdapter automatically created for me.. being
able to create a DataSet from that is fun and...
|
by: Charlie |
last post by:
Hi:
My host will not allow me use a trusted connection or make registry setting,
so I'm stuck trying find a way to hide connection string which will be
stored in web.config file. If I encrypt...
|
by: Bala Nagarajan |
last post by:
Hello,
I am using Oracle 9i in my application and facing a problem with the
connection string. In the datasource attribute of the connection string i
had to specify an entry in "tnsnames.ora"...
|
by: samcogan |
last post by:
Im writing an app that needs to let the user choose which SQL server
they want to use froma drop down box, then connect to that server.
I've been searching for ages to find a way to do this, anyone...
|
by: Sankalp |
last post by:
Hi,
I am using VB 2005. My application has many data bound controls. The
connection is stored in the app.config file.
I want the application to start with a default connection string and
while...
|
by: adeel shahid |
last post by:
I m using .NET Crystal Report but i have to create report using different servers. right now the connection string is static using store procedure but i want to change the connection string at...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
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...
|
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...
|
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...
| |