In aspx, you can directly use Session["Name"] to assign and get values. In ashx, you have to inherit the interface IRequiresSessionState . Then use!
accomplish:
public class UserInfo : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var userinfo = context.Session["userinfo"]; } public bool IsReusable { get { return false; } } }
The following code example checks the current HTTP Handler property to determine whether read and write access is required for session state values.
bool requiresSession = false;if (Context.Handler is IRequiresSessionState) requiresSession = true;
Article Citation: http://code365.club/Article?id=19