缓存 WCF 代理?
我正在尝试使用 Channel Factory 并将其缓存在我的 asp.net mvc 中。 我正在使用 PerSession 实例模式,因为我需要知道状态。 因此我无法立即关闭代理。我不想 要重新打开,每次都关闭代理。 如果我让代理保持打开状态,它会在第 12 次超时。我可以 增加并发会话超时,但我想知道是否是这样 正确的方法。 我是 WCF 新手,如果我的问题很愚蠢,请原谅。 -提前致谢 普拉特
I am trying to use Channel Factory and caching it in my asp.net mvc.
I am using PerSession Instance mode as I need to know the state.
Because of this I cannot close the proxy immediately. And I dont want
to reopen ,close proxy everytime.
If I leave the proxy open it is timing out at the 12th time. I can
increase the concurrent session timeout but I want to know if it is
the right approach to go.
I am new to WCF so pardon If my question is stupid.
-Thanks in advance
Pratt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案可能是激活表单身份验证元素中的 movingExpiration 属性,尽管默认情况下该属性是打开的。这样,每次调用后,计时器都会重置为超时值,以便会话在使用时保持活动状态。
请参阅此 MSDN 链接:表单身份验证和表单验证slipExpiration 属性
编辑 - 对评论的回应:
是的,当达到会话超时时,您将需要重新进行身份验证,然后才能再次访问服务。您应该将超时值设置为您认为用户不再活动的不活动长度(以分钟为单位)(默认 30 分钟),然后如果用户继续呼叫,滑动到期将重置该值。我会尝试做一些简单的测试,将超时设置为 1 分钟,并在不同的场景下向自己证明这一点。
The answer maybe activating the slidingExpiration property in the forms authentication element, although by default this is turned on. With this, after each call the timer is reset to the timeout value so the session stays active whilst it's in use.
See this MSDN Link: Forms Authentication & slidingExpiration property
EDIT - response to comment:
Yes, when the session timeout is reached you will need to reauthenticate before being able to accesss the services again. You should set the timeout value to the length of inactivity (in minutes) that you would consider the user is no longer active (default 30 mins), then the sliding expiration will reset this value if the user keeps calling. I'd try doing some simple tests with the timeout set to 1 minute with different scenarios to prove it to yourself.