Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programmatically write to app settings in web.config? 1

Status
Not open for further replies.

DatabaseDude

Programmer
Nov 7, 2005
112
US
Is it possible to write settings to the web.config file?

I'm deploying an app, and the smtp server name will be stored in web.config. I know that if the value changes, the web.config file can be edited per usual. However, I was wondering if this would be something that could be set by the admin from his protected aspx pages.

[I googled for solutions, but found nothing; I would have searched for the answer on here as well, but search is currently down]
 
Yes you can but bear in mind that changes to the web.config file will reset the app domain which will reset all the sessions and kick your users out (which won't be very good for performance).


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Ouch! Yes, that would be something to be mindful of, wouldn't it? :)

What if prior to changing such a value, the user gave notice to users, then went into ASP.NET Configuration and clicked on "Take application offline"?

BTW is there a different way to control application being online or offline, without using the built-in ASP.NET Configuration tool? (of course if it's in the current app, and it's taken offline, the user would get locked out) So maybe like a desktop shortcut that runs a small utility?

Not trying to be complicated, just trying to build in some preferences and settings for clients who want to have some control over the app; it's easier to explain how to go to a certain page and enter something in a control, than to edit web.config :)

Thanks!
Bryant
 
you could also store the information in external xml files. this will require you to construct custom objects to manage the xml files, and it will not be as secure, but it would provide you the flexibility you're looking for.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
BTW is there a different way to control application being online or offline, without using the built-in ASP.NET Configuration tool?
All that tool does is place a file named "app_offline.htm" in the root folder of your application and ASP.NET automatically displays it's contents to the user when any request is made. You can do this manually if needed.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top