ASP.NET C# Share session web service? Home.aspx set session, but Service.asmx get session return NULL
Home.aspx
Home.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
Session["UserId"] = "Guest";
}
Service.asmx
Service.asmx.cs
[WebMethod(EnableSession = true)]
public string EchoSession()
{
String json = "{\"id\":\"" + System.Web.HttpContext.Current.Session["UserId"] + "\"}";
return json;
}
Summary: Web services don't have Session by default. Add an attribute to the WebMethod.
Title:
C# Share session web service
Description:
ASP.NET C# Share session web service? Home.aspx set session, but Service.asmx get session return NULL Home.aspx Home.aspx.cs protected v...
...
Rating:
4