Hi!
Yes, web.config is the file to use. You can also use machine.config for
stuff like connection strings so they won't be stored on a public area. The
config files are XML files, so you can use any XML editor to edit them. ;)
In your web.config file, add an element called <appSettings> between
<configuratio n> and <system.web>, inside the appSettings element, use the
<add/> element to add variables:
<configuratio n>
<appSettings>
<add key="SomeKey" value="SomeValu e"/>
....
</appSettings>
<system.web>
.....
</configuration>
Now you can access these values by the
System.Configur ation.Configura tionSettings class' static AppSettings
property. Like this:
using System.Configur ation;
....
public class MyPage : System.Web.Page
{
....
public void Page_OnLoad()
{
Response.Write( ConfigurationSe ttings.AppSetti ngs.Get("SomeKe y"));
}
....
}
By the way.. Windows Applications can also use config files. Name the file
yourprogram.exe .config and you're up and running. ;)
HTH,
Lars-Erik
"Tumurbaata r S." <sp********@mag icnet.mn> wrote in message
news:eV******** ******@TK2MSFTN GP12.phx.gbl...
Hi!
In old ASP I used Application collection to store configuration settings
like ADO connection string. In .NET, it seems, the preferred method is
using Web.config file. Yes? If I'm right then how to add (manually) and
retrieve (from app) custom values?
Thank you!
P.S. It seems, VS.NET does not have tool to modify Web.config file.
Developer should update this file manually as text?