I have published solution for this problem as answer to another question.
Look at the application life cycle overview (https://msdn.microsoft.com/en-us/library/bb470252(v=vs.140).aspx), particulary the row The request is processed by the HttpApplication pipeline. in the table Life Cycle Stages.
Whereas the function GetHttpHandler
of your IRouteHandler
object is invoked in the phase 10 (Raise the MapRequestHandler event.) of the pipeline, Session is restored in the phase 12 (Raise the AcquireRequestState event.). That is why you cannot access Session variables during the GetHttpHandler function and RequestContext.HttpContext.Session
is always null
.