Solved

ASP.net Global.aspx

Posted on 2004-03-24
4
1,116 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Out the count variables 6 53
Time/Date Query 11 41
JSON error 4 64
Want the count number from this QUery 2 49
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…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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