Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Sep 22, 2006 11:11 AM|LINK
Yes, I do understand what's wrong with your approach. Although it is a long story, I'll have a go and try to briefly explain it.
In the ASP.NET runtime, request processing is performed by executing a sequence of steps. One of these steps is responsible for session state establishment, meaning, associating the session state container (corresponding to the current request) with the
current HttpContext. This step is implemented by the HttpModule System.Web.SessionState.SessionStateModule.
Another request processing step performs URL-endpoint mapping, where endpoint must be: a type that implements IHttpHandlerFactory;
or a type that implements
IHttpHandler. If the specified endpoint (in web.config) is a type that implements
IHttpHandlerFactory, its GetHandler method is called immediately.
The problem is that URL-endpoint mapping is performed prior to session state establishment. This means that it is
impossible to access session state variables in the custom factory GetHandler method, simply because the ASP.NET architecture is not designed to provide session state access to the factory. This means that your approach is not valid, given
the runtime design.
In order to give you a solution, I require a better explanation of what you intend to accomplish.