Solved

ASP.net Global.aspx

Posted on 2004-03-24
4
1,112 Views
Last Modified: 2008-03-17
I read from the web.config in my global.aspx. How can I get this variable from my form?

protected void Application_Start(Object sender, EventArgs e)
{
   propertyId = ConfigurationSettings.AppSettings.Get("ID");      
}
0
Comment
Question by:jeremiahscott
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:sforcier
ID: 10670143
Have you tried:

propertyId = ConfigurationSettings.AppSettings("ID");
0
 

Author Comment

by:jeremiahscott
ID: 10670285
yea, i call that once when my app starts up in global.aspx. should i just call that each time from my form instead? is it costly to do that?
0
 
LVL 6

Accepted Solution

by:
sforcier earned 100 total points
ID: 10670497
You could do the following:

'in global.asax
protected void Application_Start(Object sender, EventArgs e)
{
   Application["propertyId"] = ConfigurationSettings.AppSettings.Get("ID");    
}

'in any webform
int x = Application["propertyId"]; //Assuming it's an integer, you get the idea

You mention the alternative of loading from the webconfig in the form itself, which is actually what I'd recommend (conditionally). Using application variables uses memory, and unless you're using this propertyId on every web form, you're wasting memory by loading it in an application variable.
0
 

Author Comment

by:jeremiahscott
ID: 10670535
gotcha. thx!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now