Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Session.SessionID in ActionFilterAttribute

I have created Controller Attribute and would like to read SessionId but get error "An object reference is required for the non-static field, method, or property". What is the best method to access session object from controller attribute?

public class DetectChangesAttribute :ActionFilterAttribute
{
    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        //I get error on Controller.Session.SessionID
        ConversionQueueModel.Remove(Controller.Session.SessionID, "");
        base.OnActionExecuting(filterContext);
    }
}
like image 759
Tomas Avatar asked Mar 26 '12 14:03

Tomas


1 Answers

Have you tried this?

filterContext.HttpContext.Session.SessionId
like image 169
Leniel Maccaferri Avatar answered Oct 20 '22 07:10

Leniel Maccaferri