【发布时间】:2014-10-17 05:04:48
【问题描述】:
我的机器上托管了两个应用程序,网址如下。
"//mymachine:port1/appl"
"//mymachine:port2/app2"
App1 和 app2 使用相同的登录凭据。我的问题是,当用户注销 App2 时,app1 似乎也已注销并重定向到登录页面。 IIS中是否有一些设置,以便App2中的注销不会影响App1。
【问题讨论】:
标签: asp.net asp.net-mvc cookies iis-7.5
我的机器上托管了两个应用程序,网址如下。
"//mymachine:port1/appl"
"//mymachine:port2/app2"
App1 和 app2 使用相同的登录凭据。我的问题是,当用户注销 App2 时,app1 似乎也已注销并重定向到登录页面。 IIS中是否有一些设置,以便App2中的注销不会影响App1。
【问题讨论】:
标签: asp.net asp.net-mvc cookies iis-7.5
浏览器根据域名称和路径存储cookie,如果您注意firebug的cookie选项卡,您会看到localhost 存储在 localhost 域名 中。所以两个应用程序具有相同的 cookie。但您可以将应用程序 cookie 存储在不同的路径上。
Response.Cookies.Add(new HttpCookie("Data")
{
Value = "....",
Path = "/app1"
});
Response.Cookies.Add(new HttpCookie("Data")
{
Value = "....",
Path = "/app2"
});
【讨论】:
如果您在两个应用程序中都使用会话登录,您的问题将得到解决
例如创建会话为
session["email"] = emailtextbox.text
在应用程序中创建它并检查每个表单中的会话
【讨论】:
最终通过设置不同的表单认证cookie路径解决了这个问题。
在app1中设置为
<authentication mode="Forms">
<forms loginUrl="~/MyController/MyAction" timeout="60" path="/"/>
</authentication>
在app2中设置为
<authentication mode="Forms">
<forms loginUrl="~/MyController/MyAction" timeout="60" path="/SomeOtherPath"/>
</authentication>
【讨论】: