asp.net - ASP.NET MVC 中每个用户变量的 Session 替代方案

标签 asp.net .net asp.net-mvc iis-7

我正在开发一个 MVC 3 应用程序,该应用程序将托管在具有多工作进程设置的网络农场中。大约有十几个变量存储在 Session 中,但由于 IIS 设置而丢失。

迷路我的意思是,当登录过程成功时,我通过日志看到我已经设置了 session 变量,但是在重定向操作和登陆 Controller 操作之后, session 变量通常是空的。我不确定这是否相关,但这是在 HTTPS 中。

我们正在研究将存储在 Session 中的特定于用户的设置转移到其他机制的可能性,但有一个变量我无法做到这一点。鉴于上述部署环境,我有以下问题。

  • cookie 是我唯一(最好的?)替代为用户特定设置存储 session 变量的方法吗?
  • 如果是这样,是否有一种安全机制来编写 cookie,因此它们无法被操纵并且仍然可以在多服务器环境中读取?
  • 据我了解 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/

    相关文章:

    c# - 无法为表中的标识列插入显式值

    asp.net - 在 ASP.NET MVC 中使用 Razor 创建可重用的 HTML View 组件

    c# - CLR:多参数聚合,参数不在最终输出中?

    javascript - 使用 Json.Net 序列化 Entity Framework 对象

    asp.net-mvc - 为什么即使使用静态机器 key ,HttpAntiForgeryException 也会随机发生?

    c# - C# 中的通用类型到配置值的映射

    asp.net - Windows Server的Web搜索引擎是开放源代码/免费的

    c# - 在ms visual studio中使用是否必须单独安装ms sql server 2005

    asp.net - XP 上使用 Visual Studio 的 IIS Developer Express

    c# - 将文本框绑定(bind)到 View 模型中的对象