Global.asax in asp.net 2.0

A

Arjen

Hi,

How can I make some variables global (public available) with the global.asax
file inside asp.net 2.0?

- I want to access these variables from code-behind files (and maybe from
aspx files).
- The global.asax haves no code-behind file.
- I want to set the values of the public variables inside the
Application_BeginRequest method.

Thanks!
 
T

Tom.PesterDELETETHISSS

I think that you want a variable that is global within the scope of a page.
If that's what you want use
HttpContext.Current.Items in your external class files
or
Context.Items in your aspx & global.asax file

An overview of global data in asp.net can be found here :
http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/

I hope it helps...
Let me know if you have any more questions..

Cheers,
Tom Pester
 
P

Peter Kellner

Hi,

How can I make some variables global (public available) with the global.asax
file inside asp.net 2.0?

use the static Application class. Here is an example of what might go
in the global.asax file:

Application["Q"] = new BlackHen.Threading.WorkQueue(rrQ);

And, in your codebehind to reference the class:

WorkQueue wq = ((WorkQueue)Application["Q"]);


This is as close to making a global as I know how to do. Hope this
helps.





Peter Kellner
http://peterkellner.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top