In Mvc3 I created an own RouteConstraint class as I implemented the IRouteConstraint interface, which means that I implemented the Match function. The only but serious problem I have that whenever the Match function is called, the session object is always null.
My simple code looks like:
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;
}
I cannot avoid using the session object since I need the "level"/"type" of the logged-in administrator. I would not like to do my things in the cotroller class either, because it would be cumbersome to maintain by time.
Thanks, Gabor
 
     
    