|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to reference web.config from classIn my asp.net application, I have created a class for
global variables and functions, and I have placed this in the app_code directory so it is available to all my pages. That part has worked fine. But now, I need to add a new funtion in this class which needs to reference web.config. How do I get a reference to web.config from this class? In other words, all my aspx pages are hooked up to web.config automatically, but not a class which I have placed in /app_code. TIA!! Tom System.Configuration.ConfigurationManager.AppSettings("key_name")
Show quoteHide quote "Tom" <T**@discussions.microsoft.com> wrote in message news:6163E118-A8E4-4A57-ACD4-79A5F1B7822F@microsoft.com... > In my asp.net application, I have created a class for > global variables and functions, and I have placed > this in the app_code directory so it is available to all my pages. > That part has worked fine. > But now, I need to add a new funtion in this class which > needs to reference web.config. How do I get a reference > to web.config from this class? > In other words, all my aspx pages are hooked up to > web.config automatically, but not a class which I have > placed in /app_code. > > TIA!! > Tom You'll also have to add a new project reference to System.Configuration or
you won't see the ConfigurationManager class. Trevor Show quoteHide quote "Michael Kolias" <mi***@alspaconsulting.com> wrote in message news:8vmdnbkMnq4OIKPZRVn-gA@speakeasy.net... > System.Configuration.ConfigurationManager.AppSettings("key_name") > > "Tom" <T**@discussions.microsoft.com> wrote in message > news:6163E118-A8E4-4A57-ACD4-79A5F1B7822F@microsoft.com... >> In my asp.net application, I have created a class for >> global variables and functions, and I have placed >> this in the app_code directory so it is available to all my pages. >> That part has worked fine. >> But now, I need to add a new funtion in this class which >> needs to reference web.config. How do I get a reference >> to web.config from this class? >> In other words, all my aspx pages are hooked up to >> web.config automatically, but not a class which I have >> placed in /app_code. >> >> TIA!! >> Tom > > If you're using .NET 2.0 then the preferred class for accessing web
configuration is the WebConfigurationManager class: http://msdn2.microsoft.com/en-us/library/ms151430.aspx HTH, Chris
ASP.NET page bring someones data upon refresh
application relative paths not working ArrayList and Structures VB.NET Determine Debug Mode Best Practice for Inserting Data into SQL in 2.0 Framework 2.0 is installed on Server 2003 but IIS stays with ASP.NET V1 GridView ODS and ConvertEmptyStringToNull="false" OBDC Oracle connection in a ASP.net web page dropdownlist in FormView "has a SelectedValue which is invalid" Creating a web app. on another PC question. |
|||||||||||||||||||||||