webservice中的代码
[WebMethod(EnableSession=true)]
public void CookieSave()
{
Session["ddd"] = "ssdfsd";
}
[WebMethod(EnableSession=true)]
public string CookieFrom()
{
if(Session["ddd"] == null)//如果空的时候返回nnn
Session["ddd"] = "nnn";
return Session["ddd"].ToString();
}
调用在asp.net中调用webservice代码
private void Button1_Click(object sender, System.EventArgs e)
{
System.Net.CookieContainer aab= new System.Net.CookieContainer();
localhost.Service1 dd = new testserver.localhost.Service1();
dd.CookieContainer = aab;
dd.CookieSave();//设置Session["ddd"]的值
}private void Button2_Click(object sender, System.EventArgs e)
{
System.Net.CookieContainer aab= new System.Net.CookieContainer();
localhost.Service1 aa = new testserver.localhost.Service1();
aa.CookieContainer = aab;
Response.Write(aa.CookieFrom());//读取出来的Session["ddd"]为nnn
}
如果正确的话应该是ssdfsd才对啊。
请教高手~~
谢谢~~~
[WebMethod(EnableSession=true)]
public void CookieSave()
{
Session["ddd"] = "ssdfsd";
}
[WebMethod(EnableSession=true)]
public string CookieFrom()
{
if(Session["ddd"] == null)//如果空的时候返回nnn
Session["ddd"] = "nnn";
return Session["ddd"].ToString();
}
调用在asp.net中调用webservice代码
private void Button1_Click(object sender, System.EventArgs e)
{
System.Net.CookieContainer aab= new System.Net.CookieContainer();
localhost.Service1 dd = new testserver.localhost.Service1();
dd.CookieContainer = aab;
dd.CookieSave();//设置Session["ddd"]的值
}private void Button2_Click(object sender, System.EventArgs e)
{
System.Net.CookieContainer aab= new System.Net.CookieContainer();
localhost.Service1 aa = new testserver.localhost.Service1();
aa.CookieContainer = aab;
Response.Write(aa.CookieFrom());//读取出来的Session["ddd"]为nnn
}
如果正确的话应该是ssdfsd才对啊。
请教高手~~
谢谢~~~
解决方案 »
- JavaScript如何读取li元素的id的值?
- public方法中怎样返回两个不同类型的值?
- showmodeldialog 如何关闭当前窗口
- 新手请问:像很多网站要注册登录才能进入论坛。用ASP.NET怎么实现的?
- 谁能借我一个eWebEditor asp.net版的控件。小弟感激不敬啊。(小弟的邮件地址:[email protected])
- 为什么FMStocks7安装结束时会出现问题,帮帮忙,谢谢各位了?
- 在服务器上为什么不能弹出网页
- 对表中的一列求和????
- 请问我的一个script程序是显示日期的,请问在vb.net里如何加到想加的位置?比如在一个表格里显示
- 跪求哪位大神能介绍下OSMPlayer,急用啊!!!!!!!!!!!!
- 寻求一个解决方法
- 请教,美工和程序员的合作问题.
应是这样
protected static localhost.Service1 dd;button1
dd = new testserver.localhost.Service1();
dd.CookieContainer = aab;
dd.CookieSave();//设置Session["ddd"]的值
button2
Response.Write(dd.CookieFrom());//读取出来的Session["ddd"]为nnn
那如果这样的话那是不是不能在多窗口中共享状态呢
比如说我可不可以在C/S中调用服务设置Session ,另外在B/S下调用服务的另外个方法获取Session中的值呢?
谢谢~~~~~