F
Francois Malgreve
hello guys,
I have some helper class in my ASP.NET pplication who basically contains
static methods. I used them as helper methods to do small jobs that I can
use at many places in my code.
As those classes methods are static, they are never associated with any
instance, then not assoicated with any HttpRequest neither.
Nevertheless in some case I ended up myself passing the Session object to my
static methods to be able to get some session related information. But then
I found the sstatic property HttpContext.Current which returns me an
HttpContext object. In which I can find all my objects related to a session,
request and response. Miracle.
Now my question is how can a static property point you to the right
request/response/session? How can this static HttpContext.Current property
point you to the right HttpContext object? Is ASP.NET mono threaded the
Context is attached some how to the thread? Or if it is multithreaded (a
thread per request I would assume) is the context attached to the thread
serving a particular request? I need to understsand the underlying mechanism
to be sure that I won't have any bug later on.
Thank you to give me any information or point me to any doc explaining the
mechanism of that static property.
Best regards,
Francois
I have some helper class in my ASP.NET pplication who basically contains
static methods. I used them as helper methods to do small jobs that I can
use at many places in my code.
As those classes methods are static, they are never associated with any
instance, then not assoicated with any HttpRequest neither.
Nevertheless in some case I ended up myself passing the Session object to my
static methods to be able to get some session related information. But then
I found the sstatic property HttpContext.Current which returns me an
HttpContext object. In which I can find all my objects related to a session,
request and response. Miracle.
Now my question is how can a static property point you to the right
request/response/session? How can this static HttpContext.Current property
point you to the right HttpContext object? Is ASP.NET mono threaded the
Context is attached some how to the thread? Or if it is multithreaded (a
thread per request I would assume) is the context attached to the thread
serving a particular request? I need to understsand the underlying mechanism
to be sure that I won't have any bug later on.
Thank you to give me any information or point me to any doc explaining the
mechanism of that static property.
Best regards,
Francois