DomainAccessGuard.Sessions 始终为空
您好,我在集成踢用户的功能时遇到问题,因为 sessionCollection 始终为空。
public void KickStaleUsers()
{
foreach (DomainAccessGuard.Session ses in DomainAccessGuard.Sessions) //<--- This is null
{
if (DateTime.Now.Subtract(ses.LastRequest).Minutes >= 60)
{
DomainAccessGuard.Kick(ses.SessionID);
Log.Info("Brugeren (" + ses.UserName + ") er logget ud grundet 60 min. inaktivitet!", this);
}
}
}
我正在从代理运行此
有人知道为什么它为空吗?
Hi I am having trouble Integrating the ability to kick users as the sessionCollection is always null.
public void KickStaleUsers()
{
foreach (DomainAccessGuard.Session ses in DomainAccessGuard.Sessions) //<--- This is null
{
if (DateTime.Now.Subtract(ses.LastRequest).Minutes >= 60)
{
DomainAccessGuard.Kick(ses.SessionID);
Log.Info("Brugeren (" + ses.UserName + ") er logget ud grundet 60 min. inaktivitet!", this);
}
}
}
I am running this from an agent
Does anybody know why it is null?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编辑:请参阅问题评论。
需要更多代码/说明。
如果
DomainAccessGuard
为 null,则发布创建对象的位置的代码。如果
DomainAccessGuard.Sessions
为空,则将代码发布到填充会话集合的位置。如果
DomainAccessGuard.Sessions
(集合)为null
,那么您需要将代码发布到实例化集合的位置 - 尽管我觉得这有点奇怪。如果您尝试访问其
UserName
的集合中的单个DomainAccessGuard.Session
为 null,则可能适用以下情况:在我看来,您是尝试从您刚刚踢出的会话中读取用户名。这不会使您的会话无效吗?
这可能有效:
这只是一个猜测,我对 DomainAccessGuard 一无所知。
EDIT: See comment to question.
More code/clarification required.
If
DomainAccessGuard
is null then post the code from where you create the object.If
DomainAccessGuard.Sessions
is empty then post the code where the sessions collection is filled.If
DomainAccessGuard.Sessions
(the collection) isnull
then you'll need to post the code where the collection is instantiated - though I'd find that a little strange.If the individual
DomainAccessGuard.Session
from within the collection that you're trying to access theUserName
of is null then the following might apply:It looks to me like you're trying to read the user name from a session you've just kicked. Wouldn't that make your session null?
This might work:
That's just a guess, I know nothing about DomainAccessGuard.
您需要调用
DomainAccessGuard.GetAccess()
来初始化Sessions集合You need to call
DomainAccessGuard.GetAccess()
to initialize the Sessions collection以下是一些 sitecore 文档,其中提供了如何减少会话超时的示例。
它作为代理运行,并且还对会话进行 Assert.IsNotNull 检查。
希望这有帮助
Here is some sitecore documentation which provides an example of how to reduce session timeout.
It runs as an agent, and also has an Assert.IsNotNull check on session.
Hope this helps