I found solutions to add Session State for web api 4.0. But I have not found one for 4.5. Could some one point how to accomplish this?
            Asked
            
        
        
            Active
            
        
            Viewed 4,083 times
        
    0
            
            
        - 
                    Does [this](http://stackoverflow.com/questions/9594229/accessing-session-using-asp-net-web-api) help? – levelnis May 18 '13 at 17:06
 - 
                    No, that links take me to a page where i can not find the code – Manuel Valle May 18 '13 at 17:25
 
2 Answers
3
            
            
        But instead of the following code in de webapiconfig
var route = config.Routes.MapHttpRoute(...
use the RoutTable class
var route = RouteTable.Routes.MapHttpRoute(...
        Thirumalai murugan
        
- 5,698
 - 8
 - 32
 - 54
 
        Michael
        
- 31
 - 2
 
3
            
            
        You can test the incoming request using RouteTable.Routes.GetRouteData to determine whether it is an Web API request:
    protected void Application_PostAuthorizeRequest()
    {
        // WebApi SessionState
        var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(HttpContext.Current));
        if (routeData != null && routeData.RouteHandler is HttpControllerRouteHandler)
            HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
    }
        Stumblor
        
- 1,118
 - 8
 - 16