webserver中为什么我的Session保存不了

bigbear_lj 2004-03-11 04:24:09
[WebMethod(Description ="欢迎",/*TransactionOption = TransactionOption.RequiresNew,*/EnableSession = true ) ]
public string HelloWorld()
{
if(Session["MyCount"] == null)
{
Session["MyCount"] = 1;
}
else
{
Session["MyCount"] = ((int) Session["MyCount"]) + 1;
}
return "Hello World" + Session["MyCount"].ToString();
}

...全文
41 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangsuipeng 2004-03-24
  • 打赏
  • 举报
回复
yourWebService() is the constructor of the proxy class
huangsuipeng 2004-03-24
  • 打赏
  • 举报
回复
Enable sessions for the client.

What you need to add is a single line of code again, with a simple assignment to the CookieContainer in the constructor.

public yourWebService() {
this.Url = "http://...../**.asmx";
this.CookieContainer =
new System.Net.CookieContainer();
}


八爪鱼-杭州 2004-03-24
  • 打赏
  • 举报
回复
把sv的cookiecontainer指向同一个cookiecontainer对象


110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧