HttpContext out of scope when in thread

J

JF

I found a solution that i'm thinking quiet good :p :

Every time i need to access to an Application object, i use a wrapper class

Then i have something like this:

WSApplication.Objects.TempZone

In the Application_Start event (global.asax), I initialise a static member of my wrapper class:

private static HttpContext Context;

=> WSApplication.Objects.Init();

Then when i call a static ascessor of the class i m doing something like that:

public TempZone TempZone
{
get
{
return (TempZone)Context.Application["TempZone"];
}
}


With this solution all the threads can access easily to the application object :)
 
B

Brock Allen

You can already do this via:

HttpContext.Current.Application





> I found a solution that i'm thinking quiet good :p :
> Every time i need to access to an Application object, i use a wrapper
> Then i have something like this:
> WSApplication.Objects.TempZone
> In the Application_Start event (global.asax), I initialise a static
> member of my wrapper class:
> private static HttpContext Context;
> => WSApplication.Objects.Init();
> Then when i call a static ascessor of the class i m doing something
> public TempZone TempZone
> return (TempZone)Context.Application["TempZone"];
 

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

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top