如何强制IIS托管的WCF或ASMX [webservice]只读取会话对象? [英] How to force an IIS hosted WCF or ASMX [webservice] to use session object readonly?

查看:174
本文介绍了如何强制IIS托管的WCF或ASMX [webservice]只读取会话对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在进行我的第一次ajax尝试时,我决定立即使用IIS托管的WCF。奇怪的是,如果启用了sessionmode,WCF无法为同一个用户/会话并行处理多个请求!如果在asp.net上禁用sessionmode,则会并行处理请求。更明亮/客户端可以执行几个不同的请求,其中一些请求长时间运行。这将阻止所有进一步的requets并使我的ajax应用程序无法使用。

While making my first ajax attempts, I decided also, to go to use IIS hosted WCF now. The strange thing is, that the WCF cannot process several requests parallel for the same user/session, if sessionmode is enabled! If sessionmode is disabled on asp.net, the requests are processed parallel. The broser/client may execute several different requests, where some of them are long running. This blocks all further requets and make my ajax app unusable.

这也适用于asmx [webservices]。我有一个很大的希望,就是使用IReadOnlySessionState接口编译webservice方法,但是这对于网页的反对 - 没有影响。但我需要[大多数时候只读取]访问asp.net会话!

This applies to asmx [webservices] also. I had a big hope, to compile the webservice methods using "IReadOnlySessionState" interface, but this has - in oppsite to webpages - no influence. But I need access [most times readonly] to the asp.net session!

有人知道这个问题的任何解决方案。

Does someone knows any solution to this problems.

无论如何,非常感谢!

br - mabra

br--mabra

推荐答案

在.NET 4中,您可以在 Application_BeginRequest中执行此操作

In .NET 4, you can do this in Application_BeginRequest

if (Context.Request.Path.EndsWith("xxx.svc"))
   Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly);

这篇关于如何强制IIS托管的WCF或ASMX [webservice]只读取会话对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆