我正在开发一个 MVC 3 应用程序,该应用程序将托管在具有多工作进程设置的网络农场中。大约有十几个变量存储在 Session 中,但由于 IIS 设置而丢失。
迷路我的意思是,当登录过程成功时,我通过日志看到我已经设置了 session 变量,但是在重定向操作和登陆 Controller 操作之后, session 变量通常是空的。我不确定这是否相关,但这是在 HTTPS 中。
我们正在研究将存储在 Session 中的特定于用户的设置转移到其他机制的可能性,但有一个变量我无法做到这一点。鉴于上述部署环境,我有以下问题。
System.Runtime.Caching
在上述 IIS 配置中运行时遇到同样的问题。真的吗? 最佳答案
Are cookies my only (best?) alternative to storing Session variables for user-specific settings?
不 - 它们是最糟糕的方法。想到的三个原因:
If so is there a secure mechanism for writing cookies so they cannot be manipulated and can still be read in a multi-server environment?
见上面的回答。
As I understand it System.Runtime.Caching suffers from the same problem when ran in the above IIS configuration. Is that true?
真的。您应该使用任何不在 proc 中的 State Providers。您可以使用 Sql Server 来存储 session 数据 - 前提是您的对象显然是可序列化的 - 或者 State server mode
mode="stateserver"
Read here更多细节
关于asp.net - ASP.NET MVC 中每个用户变量的 Session 替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10584659/