配置时[WebMethod(EnableSession = true)] //启用会话
public string UserList1()
{
System.Threading.Thread.Sleep(1000 * 60 * 5); //模似计算5分钟
return "abc1";
}[WebMethod(EnableSession = true)] //启用会话
public string UserList2()
{
return "abc2";
}在我的程序中只有登陆与退出才会对会话进行写,其他时候都是只读(主要是权限),
因此在页面 EnableSessionState="ReadOnly" 这样配置,而如果是实现IHttpHandler接口的对象则再加这个
System.Web.SessionState.IReadOnlySessionState接口,都能很好的解决问题.但在WEB服务方面,就不知道如何解决了同一会话(不同实例,不同模块,异步等)调用以上两个方法
先调用1再调用2,2会被阻塞到1完成才返回,但放在页面上就没有问题(只要配置EnableSessionState).解决过的朋友帮助一下!
public string UserList1()
{
System.Threading.Thread.Sleep(1000 * 60 * 5); //模似计算5分钟
return "abc1";
}[WebMethod(EnableSession = true)] //启用会话
public string UserList2()
{
return "abc2";
}在我的程序中只有登陆与退出才会对会话进行写,其他时候都是只读(主要是权限),
因此在页面 EnableSessionState="ReadOnly" 这样配置,而如果是实现IHttpHandler接口的对象则再加这个
System.Web.SessionState.IReadOnlySessionState接口,都能很好的解决问题.但在WEB服务方面,就不知道如何解决了同一会话(不同实例,不同模块,异步等)调用以上两个方法
先调用1再调用2,2会被阻塞到1完成才返回,但放在页面上就没有问题(只要配置EnableSessionState).解决过的朋友帮助一下!
解决方案 »
- 从数据库中读出文件提供给用户下载
- 劳烦各位大虾帮帮忙,sql语句在事务中执行也区分顺序吗?
- vs2005下面不建虚拟目录也能打开?
- ********************请教关于.netRemoting的问题***************************
- 求怎么用SQL语句向ACCESS数据库里写进一条含MEMO类型字段的纪录
- *********************帮忙啊,关于如何提升w3p.exe进程运行帐户权限****************
- CNZZ数据银行API有C#-SDK吗?
- 请问那里有支持 ASP.NET 的免费主页空间?
- 要用.net做网站,请求支援~~
- 大家看这是那里的错误
- 如何用datalist控件将我存入数据库中的新闻标题按顺序显示出来?
- html标签编译后成乱码
class MultipleCachingHttpFetcher : IHttpFetcher
* Avoid server affinity.Use Session State Only Where It Is NeededTo maintain state between requests, you can use session state in your Web services by setting the EnableSession property of the WebMethod attribute to true, as shown in the following code snippet. By default, session state is disabled.[WebMethod(EnableSession=true)]
YourWebMethod() { ... }
Since you can enable session state at the Web method level, apply this attribute only to those Web methods that need it.Note Enabling session state pins each session to one thread (to protect session data). Concurrent calls from the same session are serialized once they reach the server, so they have to wait for each other, regardless of the number of CPUs.
Avoid Server AffinityIf you do use session state, in-process session state offers the best performance, but it prevents you from scaling out your solution and operating your Web services in a Web farm. If you need to scale out your Web services, use a remote session state store that can be accessed by all Web servers in the farm.以上来自msdn:
http://msdn.microsoft.com/en-us/library/ff647786.aspx
public object[] MethodInvoke(object[] objArr)