3
在Mvc3中,我创建了自己的RouteConstraint类,因为我实现了IRouteConstraint接口,这意味着我实现了Match函数。我唯一但严重的问题是,无论何时调用Match函数,会话对象始终为空。Mvc3 RouteConstraint - 会话为空
我简单的代码看起来像:
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
{
if (routeDirection != RouteDirection.IncomingRequest)
{
return true;
}
HttpSessionStateBase sessionBase = httpContext.Session; // will be null
HttpSessionState session = HttpContext.Current.Session; // this will be null either
return true;
}
,因为我需要的“级别”登录的管理员/“型”我不能避免使用会话对象。我不想在cotroller课上做我的事情,因为按时间维护会很麻烦。
感谢,的Gabor
我有同样的问题,自2011年8月22日以来你解决了你的问题吗? –
同样的问题;有没有人解决这个问题? –