[英]C# app and asp.NET session
I try build client-base desktop app using webservices. 我尝试使用Web服务构建基于客户端的桌面应用程序。 I have problem when I try send List through session. 我尝试通过会话发送列表时遇到问题。 Even though the session was created, when reference back to session no longer exists. 即使已创建会话,也不再存在对会话的引用。
[WebMethod(EnableSession = true)]
public void dodajdolisty(string login) {
bool jest = false;
if (Session["uzytkownicy"] != null) {
listaOsob = (List<string>)Session["uzytkownicy"];
foreach (string s in listaOsob) {
if (s == login) { jest = true; break; }
}
if (! jest) {
listaOsob.Add(login);
Session["uzytkownicy"] = listaOsob;
}
}
else {
listaOsob.Add(login);
// the debugger shows that the session has been created
Session["uzytkownicy"] = listaOsob;
}
}
public List<string> pobierzzlisty() {
List<string> list = new List<string>();
list = (List<string>)Session["uzytkownicy"]; // session is null
return list;
} // null
How can I fix this? 我怎样才能解决这个问题?
I think you missed to add cookiecontainer on client app, try this 我认为您错过了在客户端应用程序上添加cookiecontainer的方法,请尝试此操作
MyWebService ws= new MyWebService();
ws.CookieContainer = new System.Net.CookieContainer();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.