我需要能够在我的自定义OnBeforeExecute()
类中的ServiceRunner
覆盖中访问会话ID和其他会话数据,如下所示:
public class MyServiceRunner<T> : ServiceRunner<T>
{
public override void OnBeforeExecute(IRequestContext requestContext, T request)
{
// How to get the session ID?
// var sessionID = ??
base.OnBeforeExecute(requestContext, request);
}
}
有办法做到这一点吗?感谢。
答案 0 :(得分:2)
public class MyServiceRunner<T> : ServiceRunner<T>
{
public override void OnBeforeExecute(IRequestContext requestContext, T dto)
{
// How to get the session ID?
var sessionID = requestContext.Get<IHttpRequest>().GetSessionId();
base.OnBeforeExecute(requestContext, request);
}
}