Hello,
Is it possible (and / or wise) to add custom pieces of code inside your
Web.Config file? For example I store the connection string in Web.Config
and access it via ConfigurationSettings.AppSettings["ConnectionString"]. Is
it possible to call on ConfigurationSettings.AppSettings["MyCustomString"]
which pulls back my stored string?
For example can I add this in Web.Config:
<add key="Author" value="All articles on this site written by Inspector
Gadget & associates" />
And then from my in my code behind file
lblPageFooter.text = ConfigurationSettings.AppSettings["Author"]
Would there be any benifit doing this?
G. 6 1583
Hi,
Yes you can do that......AppSetting just stores a set of Key-Value strings,
which you can request as ConfigurationSettings.AppSettings[name of the key]
Rgds,
Bhaskar
"G" <g@nospam.comwrote in message
news:02**********************************@microsof t.com...
Hello,
Is it possible (and / or wise) to add custom pieces of code inside your
Web.Config file? For example I store the connection string in Web.Config
and access it via ConfigurationSettings.AppSettings["ConnectionString"].
Is it possible to call on
ConfigurationSettings.AppSettings["MyCustomString"] which pulls back my
stored string?
For example can I add this in Web.Config:
<add key="Author" value="All articles on this site written by Inspector
Gadget & associates" />
And then from my in my code behind file
lblPageFooter.text = ConfigurationSettings.AppSettings["Author"]
Would there be any benifit doing this?
G.
"Bhaskardeep Khaund" <bh*********@rediffmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,
Yes you can do that......AppSetting just stores a set of Key-Value
strings, which you can request as ConfigurationSettings.AppSettings[name
of the key]
Rgds,
Bhaskar
Thanks. Does it use memory even if I choose not to call on the strings? If
I have 5,000 simultaneous users, would I have used the memory for each user
just to have it stored in Web.Config, or would it only load when I requested
it from my code?
Regards,
Gary.
if I remember correctly, each time you call
ConfigurationSettings.AppSettings[name of the key] it loads all the config
keys into memory, then iterates the collection to get the value. You should
probably store then in web.config and load them into the application pool in
the app onstart event access that from your code instead.
Regards
John Timney (MVP) http://www.johntimney.com http://www.johntimney.com/blog
"G" <g@nospam.comwrote in message
news:3E**********************************@microsof t.com...
"Bhaskardeep Khaund" <bh*********@rediffmail.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>Hi,
Yes you can do that......AppSetting just stores a set of Key-Value strings, which you can request as ConfigurationSettings.AppSettings[name of the key]
Rgds, Bhaskar
Thanks. Does it use memory even if I choose not to call on the strings?
If I have 5,000 simultaneous users, would I have used the memory for each
user just to have it stored in Web.Config, or would it only load when I
requested it from my code?
Regards,
Gary.
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:SI******************************@eclipse.net. uk...
if I remember correctly, each time you call
ConfigurationSettings.AppSettings[name of the key] it loads all the config
keys into memory, then iterates the collection to get the value. You
should probably store then in web.config and load them into the
application pool in the app onstart event access that from your code
instead.
Thanks I will read up on the App Pool and App Onstart, new to all this :)
G.
by app pool I meant to say application object :)
Regards
John Timney (MVP) http://www.johntimney.com http://www.johntimney.com/blog
"G" <g@nospam.comwrote in message
news:AB**********************************@microsof t.com...
>
"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:SI******************************@eclipse.net. uk...
>if I remember correctly, each time you call ConfigurationSettings.AppSettings[name of the key] it loads all the config keys into memory, then iterates the collection to get the value. You should probably store then in web.config and load them into the application pool in the app onstart event access that from your code instead.
Thanks I will read up on the App Pool and App Onstart, new to all this :)
G.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Suresh Gladstone |
last post by:
Hi,
This is a bit with versioning and installation of
the .NET dlls. I want to perform the following,
1. A third party application will be invoking my .NET dll
through COM interop . For this I...
|
by: Richard |
last post by:
Hi,
I'm having trouble setting up a config file based trace switch & listener. I added an application config file to my console based C# program using the "Add New Application Config File" button...
|
by: jOs |
last post by:
C#B - SHARED SOURCE PROJECT FOR A C# Browser
Let's sort this stuff out once and for ALL.
===============================================================
Anyone who's having problems in...
|
by: Dominic |
last post by:
Suppose I have a web.config. I'd like to move some configuration
settings from this web.config and put it another XML file (say,
common.xml). Now, is there any way that I can modify the web.config...
|
by: sianan |
last post by:
I tried to use the following example, to add a checkbox column to a
DataGrid in an ASP.NET application:
http://www.codeproject.com/aspnet/datagridcheckbox.asp
For some reason, I simply CAN'T get...
|
by: Robert Baer |
last post by:
The following passes the test as valid, and the mouseover for the six
indicated areas also work.
I need various areas to link to another page, including the six
mentioned.
However either the MAP...
|
by: aabdis |
last post by:
Hello All....
I have a question... i have two Windows apps (one UI, and one service)
which use a common DLL that hands out database results and such to the
two apps. The DLL always connects to...
|
by: Nathan Sokalski |
last post by:
When implementing an interface in VB.NET using Visual Studio .NET 2005, it
would be nice if I could have the method/function headers inserted
automatically. Whenever we implement an event (such as...
|
by: MasterLalit |
last post by:
Hi,
i am using a app.config file in my console application.
App.config code-->
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource"...
|
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |