这是我发起会话ASP.NET + C#HttpContext.Current.Session为空(里面的WebService)
protected void Session_Start(object sender, EventArgs e)
{
HttpContext.Current.Session["CustomSessionId"] = Guid.NewGuid();
}
在我的下一个类库解决方案,我很triyng进行访问和获取零例外:
string sess = HttpContext.Current.Session["CustomSessionId"] ;
这是我在web.config中和的app.config配置(在我的库)
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<system.web>
<pages enableSessionState = "true" />
<httpModules>
<add type="System.Web.SessionState.SessionStateModule" name="Session"/>
</httpModules>
<compilation debug="true" targetFramework="4.0" />
</system.web>
(的app.config)
执行HTTP请求的哪个阶段是你调用你的类库中的方法试图访问会话? –
很难说,但我认为这不是你的会议是空的,但HttpContext.Current - 和顺便说一句:你知道你试图将一个Guid转换为一个字符串,即使这有效吗? – Carsten
其实它是在一个web服务,我没有提到(虐待编辑我的帖子) – SexyMF