我从网络服务获取数据,例如关注
string serviceUrl = "https://www.mscholid.com/assings/handlqueryrs/myprod.ashx";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serviceUrl);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
var rootResult = XElement.Parse(result);
现在我想将这个根结果放入会话
会话[" rootv"] = rootResult;
然后我想要检索它。 商店功能应该在课堂内进行
public class NileResult
{
public dynamic nilecruiseFinalData_Images(string selectedID)
{
string serviceUrl = "https://www.mscholid.com/assings/handlqueryrs/myprod.ashx";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(serviceUrl);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string result = sr.ReadToEnd();
sr.Close();
var rootResult = XElement.Parse(result);
//in here I want to store in to a session
}
}
我该怎么办呢。
答案 0 :(得分:1)
要访问请求的会话,您可以使用:
HttpContext.Current.Session["rootv"] = rootResult;
HttpContext.Current是请求的当前上下文。