HttpContext out of scope when in thread

J

J

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 :)


<Id>h7rs7L8kA0q9eVjYTgs/7Q==</Id>
 
B

Brock Allen

You can already do this via:

HttpContext.Current.Application

-Brock
DevelopMentor
http://staff.develop.com/ballen



> 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

Top