webservice访问远程webservice站下的Session的问题

[复制链接]
查看11 | 回复3 | 2021-1-27 05:47:22 | 显示全部楼层 |阅读模式
本地站http://localhost:4001,http://localhost:4002
http://localhost:4001下有ws/GetCustomer.asmx

[System.Web.Services.WebMethod(EnableSession=true)]
publicstringGetCustomer()
{
if(HttpContext.Current.Session["CustomerId"]!=null)
returnSession["CustomerId"].ToString();
else
return"hello";
}

http://localhost:4002下有
[System.Web.Services.WebMethod]
publicstringGetRemoteCustomer()
{
CustomerInfocustomerInfo=newCustomerInfo();
returncustomerInfo.GetCustomer();
}

然后再通过Jqueryajax来获取GetRemoteCustomer()的返回值。
http://localhost:4001无论登没登陆都是返回的hello.
请指点指点。谢谢

分 -->
回复

使用道具 举报

千问 | 2021-1-27 05:47:22 | 显示全部楼层
很明显是IF语句没有执行在判断&&ToString()!=""
回复

使用道具 举报

千问 | 2021-1-27 05:47:22 | 显示全部楼层
IF没执行是因为==Null啊,再ToString()不就出错了吗,有点不解
回复

使用道具 举报

千问 | 2021-1-27 05:47:22 | 显示全部楼层
早上好啊。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行