在.aspx page_load中使用Web服务会话 [英] Use webservice session in .aspx page_load

查看:92
本文介绍了在.aspx page_load中使用Web服务会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..朋友,我有一个具有Web方法userLogin的Web服务

 [WebMethod(EnableSession =  true )]
    公共 无效 userLogin(字符串 userName,字符串密码)
    {
         int  userID = userAuthenticate(userName,password);
        会话[" ] =用户ID;
    } 



我想在Default.aspx.cs page_load上使用此会话,我的编码是

 受保护的 无效 Page_Load(对象发​​件人,EventArgs e)
    {
        如果(会话[" ] != 为空)
            Response.Redirect("  false );
        其他
            Response.Redirect(" > false );
            
    } 



但是,当userID即将来临时,会话将变为空.我很困惑,请帮助我.

在此先感谢

Parveen Rathi

解决方案

查看这些链接,您可能会得到一些想法

http://support.microsoft.com/kb/816637 [ http://weblogs.asp. net/stevewellens/archive/2009/04/05/using-session-state-in-a-web-service.aspx [[WebMethod(EnableSession = true)] public void userLogin(string userName, string password) { int userID = userAuthenticate(userName, password); Session["USRID"] = userID; }



I want to use this session on my Default.aspx.cs page_load, my coding is

protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["USRID"] != null)
            Response.Redirect("MyDashboard.aspx", false);
        else
            Response.Redirect("Login.aspx", false);
            
    }



But, the session is coming null, while userID is comming. I am so confuse please help me.

Thanks in advance

Parveen Rathi

解决方案

see these links you may get Some Idea

http://support.microsoft.com/kb/816637[^]

http://weblogs.asp.net/stevewellens/archive/2009/04/05/using-session-state-in-a-web-service.aspx[^]


I think it is better to create session in page rather than webservice. Change:
1.Make webservice method to return boolean (status whether user exists or not)
2.Check that status in page & according to set session.


这篇关于在.aspx page_load中使用Web服务会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆