I use a client application to connect to a web service for an authenticated user only. Here is a simple example:
My web service code:
public class TestService : System.Web.Services.WebService { [WebMethod(EnableSession = true)] public string WelcomeMsg() { return "Hello: " + Session["UserName"] + "! Welcome to our store."; } [WebMethod(EnableSession = true)] public void SetUserName(string sName) { Session["UserName"] = sName; } }
Here is my code in the client application (Windows form, not web base):
private void btnSetName_Click(object sender, EventArgs e) { TestService.TestService ws = new TestService.TestService();
In my example, MainForm.m_ccSessionInfo is a static member, I want to save the session cookie value in this!
However, this does not work :( Ws.WelcomeMsg () always returns an empty string.
source share