IHttpHandlerFactory and problem with Session

G

Guest

I have the problem with Session object witch is null, when I implement IHttpHandlerFactory. Implementing IRequiresSessionState interface doesn't help.
My code is like this:

class MyController : IHttpHandlerFactory, System.Web.SessionState.IRequiresSessionState {
public virtual IHttpHandler GetHandler (HttpContext context, string requestType, string url, string path) {
//some stuff here
context.Session["aaa"] = "aaa"; // here Session object is null
return System.Web.UI.PageParser.GetCompiledPageInstance (url, "SomePage.aspx", context);
}
//...
}

How can I access the session object ? Please help !
 
G

Guest

It might be your first call and session isn't build in the server yet.

No. A the first time the login page is requested.
I was debugging the application, and in the global.asax in the Session_Start event i wrote sth like this:
protected void Session_Start(Object sender, EventArgs e) {
Session["test"] = "aaa";
}
And here is OK, Session object is enable.
After that IHttpHandlerFactory is called and here Session object is null.

Any ideas ?
 
N

Natty Gur

first of all just for your knowledge:
I cant describe all request life cycle but
1) context object create by HttpRuntime.ProcessRequestInternal.

2) Session is implement as Module and get called by HttpApplication
InitModules. HttpApplication set application context to session just if
session ID already exist as cookie or embedded in URL (cookieless).

3) just then application ResumeSteps and call IHttpHandlerFactory from
MapHandlerExecutionStep.

Session_Start fired when SessionStateModule create new session on your
first call. but context still don't have reference to session on
IHttpHandlerFactory.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top