我创建了控制器属性,想要读取SessionId但得到错误" An object reference is required for the non-static field, method, or property
"。从控制器属性访问会话对象的最佳方法是什么?
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);
}
}
答案 0 :(得分:10)
你试过这个吗?
filterContext.HttpContext.Session.SessionId