Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Sep 20, 2006 06:54 PM|LINK
That is a really interesting question! Did anybody find a solution of how to access the Session variables inside a HttpHandlerFactory?
I tried now multiple things and the least worse one, which still does not work is this one, I think:
public IHttpHandler GetHandler(HttpContext context,
string url, string pathTranslated)
string newUrl = url;
Match match =
newUrl = this.siteRegex.Replace(url,
IHttpHandler handler =
PageParser.GetCompiledPageInstance(newUrl, context.Server.MapPath(newUrl), context);
HttpSessionState session = (handler
session["VALUE"] = match.Value;
context.Session is still null, HttpContext.Session is null and if I try to access the Session from the handler I get an exception that the session state can only be used if enableSessionState is set to true and so forth.
MyPage implements IRequiresSessionState, the property EnableSessionState is set to true and I do use the session inside the page_load and so on. I just cannot access it from the HttpHandlerFactory.
Purpose of that factory is to extract a value from the url, redirect the user to the correct page and set some values othe session that I use to fetch data, but that should not be setable via the querystring.