【问题标题】:Restricting Authorization cookie with forms authentication使用表单身份验证限制授权 cookie
【发布时间】:2013-08-06 08:53:58
【问题描述】:

我的 Web 应用程序使用表单身份验证。它工作正常。但是,当我将同一应用程序的 2 个实例安装为虚拟目录时,我可以使用相同的 cookie 登录到这两个实例。有没有办法将它保存到单个虚拟目录中?

这是我的 web.config。

<authentication mode="Forms">
  <forms name="MyAppAuth" loginUrl="~/secured/login" protection="All" timeout="30" slidingExpiration="true" path="/">
    <credentials passwordFormat="Clear">>
    </credentials>
  </forms>
</authentication>

【问题讨论】:

    标签: authentication iis cookies web-config


    【解决方案1】:

    我不确定这里使用的是什么技术,但我猜想 path="/" 用于创建 cookie(您可能可以使用浏览器开发工具来确定)。尝试将路径设置为每个 webapp /app1 /app2 的根目录

    【讨论】:

    • 感谢路径提示。我还必须更改在 MVC 层中设置 cookie 的路径。我改了:FormsAuthentication.SetAuthCookie(userName, rememberMe,"/");到 FormsAuthentication.SetAuthCookie(userName, rememberMe);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-29
    • 1970-01-01
    • 2012-02-18
    • 1970-01-01
    • 2015-05-19
    • 2011-09-27
    相关资源
    最近更新 更多