IHttpHandlerFactory and Session problem !

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 !

Bartosz Krzywicki
 
V

Vadim Chekan

Correct me if I'm wrong but Factory is not intended to handle requests,
but to return handler which will do.
Factory does not analize request content.
If you want to handle sessions, you need to setup your own Handler.
See documentation for <httpHandlers> tag.

public class ExcelReportHandler : IHttpHandlerFactory {
public IHttpHandler GetHandler(HttpContext context, string requestType,
string url, string pathTranslated)
{
// Do something useful here
return PageParser.GetCompiledPageInstance(url, pathTranslated, context);
}
}

Regards
Vadim Chekan.

P.S. I assume you did not forget to register handler in web.config :)
 

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,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top