Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.. Friends I have a web service having web method userLogin
C#
[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

C#
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
Posted

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.
 
Share this answer
 
Comments
Parveen Rathi 9-Jul-12 1:43am    
Thansk for your response but, would you please explain how to check webserviec method return value in page
pradiprenushe 9-Jul-12 1:52am    
You are calling it in code behind or aspx page?
pradiprenushe 9-Jul-12 1:59am    
Create object of your webservice class
// .cs file of page
localhost.WSClass objUser = new localhost.WSClass();

bool IsUserPresent;
IsUserPresent = objUser.userLogin();

if(IsUserPresent )
Response.Redirect("MyDashboard.aspx", false);
else
Response.Redirect("Login.aspx", false);


webservice changes

[WebMethod(EnableSession = true)]
public bool userLogin(string userName, string password)
{
int userID = userAuthenticate(userName, password);
//you ac have diffrent logic here to check user present or not
//if present
return true;
//else
return false;

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900