Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 18th, 2009, 04:37 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Question Change web config at runtime

Hi,

I have a setup page which appears the first time a client runs the web site which prompts for server, dbname etc which then sets the connection string & some app settings in the web.config. How do I reload these settings so the user can carry on to the main site without making the user reopen the site?
Thanks for any help
Louisa
  #2 (permalink)  
Old February 18th, 2009, 05:13 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi.

You usually don't ask about databases and that type of things to a web user. Why do you want to do that?
If you are giving a complete website to the user, you will have to instruct him on how to modify config.web.
The only thing you can do to change it, If I'm not confused, is restart IIS...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
  #3 (permalink)  
Old February 18th, 2009, 05:39 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
The website will be installed on the webserver by the client's IT department & I am tryng to make it as seamless as possible so that when they have entered the info it will go straight to the site so they can verify that it works.
  #4 (permalink)  
Old February 18th, 2009, 01:48 PM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi there,

You may want to take a look here: http://www.odetocode.com/Articles/418.aspx

It's a nice introduction in working with the configuration API to write to config files.

Hope this helps,

Imaer
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old February 18th, 2009, 03:21 PM
Authorized User
 
Join Date: Dec 2008
Location: London
Posts: 50
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Quote:
Originally Posted by louisa68 View Post
Hi,

I have a setup page which appears the first time a client runs the web site which prompts for server, dbname etc which then sets the connection string & some app settings in the web.config. How do I reload these settings so the user can carry on to the main site without making the user reopen the site?
Thanks for any help
Louisa

To me your approach is wrong if I have understood your question correctly. In above scenario you would not use web.config for storing the website configuration rather an XML File.

You will ask the user for the settings and store them in the XML file and load them back into Memory(cache) and you will use it from Memory there after again.

You can also make changes and save it to the XML configuration file again at runtime without need to of WebServer or App Pool restart.

Regards
  #6 (permalink)  
Old February 19th, 2009, 09:20 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Quote:
Originally Posted by Imar View Post
Hi there,

You may want to take a look here: http://www.odetocode.com/Articles/418.aspx

It's a nice introduction in working with the configuration API to write to config files.

Hope this helps,

Imaer
Hi, I looked at this and it said "Another caveat is that the ASP.NET runtime watches web.config and will restart the web application when a change occurs. Specifically, the runtime will create a new instance of your application inside of a new AppDomain anytime you write to web.config. A restart can have a performance impact, so writing to web.config should not occur often." but my website doesn't restart as if it did it would pick up my changes and not show the setup page again,
I have the following code in after the changes are saved to the web config but they don't seem to help.
System.Configuration.ConfigurationManager.RefreshS ection(.ConnectionStrings.SectionInformation.Name)
System.Configuration.ConfigurationManager.RefreshS ection(.AppSettings.SectionInformation.Name)

If I exist & go back into the site then it doesn't show the setup page again as the changes are being saved correctly, I just want to not have to do it manually, any other ideas out there?

  #7 (permalink)  
Old February 19th, 2009, 09:22 AM
Authorized User
 
Join Date: Feb 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by zeronexxx View Post
To me your approach is wrong if I have understood your question correctly. In above scenario you would not use web.config for storing the website configuration rather an XML File.

You will ask the user for the settings and store them in the XML file and load them back into Memory(cache) and you will use it from Memory there after again.

You can also make changes and save it to the XML configuration file again at runtime without need to of WebServer or App Pool restart.

Regards

Hi,

When I say client I'm not talking about each individual user I am talking about an organisation as a whole, this setup only needs to happen once per site and never changes again.
  #8 (permalink)  
Old February 19th, 2009, 11:02 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Quote:
I just want to not have to do it manually, any other ideas out there?
Not sure what you're asking it. It seems to work fine but then what?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #9 (permalink)  
Old February 19th, 2009, 03:54 PM
Authorized User
 
Join Date: Dec 2008
Location: London
Posts: 50
Thanks: 1
Thanked 5 Times in 5 Posts
Exclamation

Quote:
Originally Posted by louisa68 View Post
Hi,

When I say client I'm not talking about each individual user I am talking about an organisation as a whole, this setup only needs to happen once per site and never changes again.

Hi Everyone

Can someone please correct me if I am wrong in the above post of mine? I mean my approach.

And Even if you store the configuration in an other XML file other web.config.
You will only ask the user if the configuration is missing from Memory(cache) and XML configuration file as also missing, which will be true only for the first user.


Some people tell me that I need help some people ...........................

Last edited by zeronexxx; February 19th, 2009 at 03:57 PM.
  #10 (permalink)  
Old February 19th, 2009, 07:07 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Cool

Quote:
Originally Posted by louisa68 View Post
Hi,

When I say client I'm not talking about each individual user I am talking about an organisation as a whole, this setup only needs to happen once per site and never changes again.
Then you will have a sort of specialized user (it has to at least set up a IIS!), so why not just add a help file to tell the user what to update and where and you forget about all this problems?
I love configurations UI (always do everything you can for the user), but in this case this seems to be rather unnecesary...
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
impersonation through web.config and runtime xile ASP.NET 1.0 and 1.1 Professional 0 November 20th, 2008 11:09 AM
web.config vs. app.config darlo Visual Studio 2005 11 August 20th, 2008 07:23 AM
Change datasource of crystal report at runtime check123 Pro VB 6 1 March 21st, 2008 05:45 AM
web.config sonny1 ASP.NET 2.0 Basics 1 October 20th, 2007 01:40 PM
How to change an ASP: Image Url at runtime ergaurav.nex ASP.NET 1.0 and 1.1 Professional 2 September 5th, 2006 03:44 AM



All times are GMT -4. The time now is 04:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.