本地计算机上的IIS无法保存会话状态 [英] IIS on Local Machine Not Saving Session State

查看:105
本文介绍了本地计算机上的IIS无法保存会话状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在我的开发机器上有一个IIS的本地实例,正在使用它来开发ASP.NET MVC应用程序.我有IIS8,目前该网站已加载,除了会话状态外,其他一切似乎都正常运行.

I currently have a local instance of IIS on my development machine with which I am working on development of an ASP.NET MVC application. I have IIS8, and currently the site loads, everything seems to be working fine except for session state.

单步执行我的代码时(所有这些代码在我们的演示服务器上都可以正常工作-所以我知道这不是代码),似乎会话变量已设置好,没有引发任何异常.但是,每次尝试访问这些变量之一时,该值都会以空字符串(")的形式返回.我已经检查了我知道要在web.config中查找的内容,以及IIS中的设置没有运气.我的Web.Config sessionState设置如下所示:

When stepping through my code (all of which works fine on our demo server - so I know it's not the code), it seems the session variables are set without any exceptions being thrown. However, any time I attempt to access one of those variables, the value is returned as an empty string (""). I have checked what I know to look for in web.config, as well as settings in IIS with no luck. My Web.Config sessionState settings look like this:

<sessionState mode="InProc" timeout="240" />

我尝试在此处添加其他设置,例如无cookie等等,但是我没有任何运气.我还使用了IIS中的设置,当前设置在此屏幕快照中: http://screencast.com/t/Vny4uUqMleB

I have tried adding other settings in here like cookieless, etc... However I haven't had any luck. I have also played with settings in IIS, current settings are in this screenshot: http://screencast.com/t/Vny4uUqMleB

添加一些会话状态代码以供参考.请注意,尽管我努力使他们切换到C#,但该系统还是用VB编写的:(

首先,这将是设置它的一个示例-我们有一个用于管理状态(会话,cookie,应用程序等)的类.键"和值"都是传入的字符串变量.

Firstly, this would be an example of it being set - we have a class for managing state (session, cookie, app, etc). both "key" and "value" are string variables passed in.

HttpContext.Current.Session(key) = value

在读取值的情况相同的情况下,代码被包装在用于管理状态的类中,但这将是重要的一行:

And when reading the value, same situation, the code is wrapped in a class for managing state, but this would be the important line:

  //Read value from session state
  If Not (HttpContext.Current.Session(key) Is Nothing) Then
    strValue = HttpContext.Current.Session(key).ToString()
  End If

如果任何人都可以给我一些指导,以指导下一步的工作,可能会影响到什么的事情,或者实际上有任何线索,我将不胜感激!

If anyone can give me some guidance on what to look at next, what things could potentially be affecting it, or really any clues whatsoever, I'd appreciate it!

推荐答案

在主帖子的评论中所有归功于PeterB.他向我发送了此链接 https://www.iis.net/configreference/system.webserver/asp/session

All credit to Peter B in the comments to the main post. He sent me to this link https://www.iis.net/configreference/system.webserver/asp/session

具体来说,在设置完一切后,迫使您安装ASP库的部分对我来说是固定的.转到IIS中的ASP图标,确保已设置会话,重新启动调试,并且所有会话问题都消失了.

Specifically, the portion forcing you to install the ASP libs after things are set up is what fixed it for me. Went to the ASP icon in IIS, made sure that session was set up, restarted debug, and all my session issues went away.

这篇关于本地计算机上的IIS无法保存会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆