我在webservice中定义了两个WebMethod,在测试这个webservice时还好好的,session传递的很好,但在页面中调用login时,在testSession()就
我在webservice中定义了两个WebMethod,在测试这个webservice时还好好的,session传递的很好,但在页面中调用login时,在testSession()就显示不了session的值了,怎么回事呀????
[WebMethod(EnableSession=true)]
public string login(string phoneNum,string pwd)
{
myConn=new SqlConnection(strConn);
myConn.Open();
FormsAuthentication.HashPasswordForStoringInConfigFile(pwd.Text, "sha1");
strSQL="select * from ESM_GroupUser where RegPhone='"+phoneNum+"'and Passwd='"+pwd+"'";
myCommand=new SqlCommand(strSQL,myConn);
reader= myCommand.ExecuteReader();
if(reader.Read())
{
reader.Close();
Session["login"]=phoneNum;
return (string)Session["login"];
}
else
{
reader.Close();
return null;
}
[WebMethod(EnableSession=true)] //测试login的值的
public string testSession( )
{
if (Session["login"]==null)
return null;
else
return (string)Session["login"];
}