Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.net Global.aspx

Posted on 2004-03-24
4
Medium Priority
?
1,134 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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