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日以來你解決了你的問題嗎? –
同樣的問題;有沒有人解決這個問題? –