从自定义MvcRouteHandler访问SessionState

时间:2011-06-23 08:51:45

标签: asp.net-mvc asp.net-mvc-routing

public class CustomRoutingHandler : MvcRouteHandler
{
  protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
  {

     requestContext.HttpContext.Session is NULL;
     //Is there any way to access Session from there ?

     return FindHttpHandler(requestContext);
     // In created handler Session is not null
  }
}

1 个答案:

答案 0 :(得分:0)

也许您遇到此问题:请参阅http://www.heartysoft.com/aspnet-routing-iis7-remember-modules

解决方案是再次删除并添加会话状态模块。

另请参阅相关的SO问题:HttpContext.Current.Session is null when routing requests