ASP.NET站点无意*享登录cookie

时间:2022-11-06 01:57:38

I have a few ASP.NET sites running on one IIS server, of course using different ports. The sites allow for logging in via forms authentication. Session state is stored on a local state server. My problem is that when a user logs into one sites and then navigates to another, they get an exception from the second site and have to close/reopen their web browser to be able to access it. My guess is that the cookie from the first site is making it appear that they're logged in on the second one as well (though I could be completely wrong about this).

我有几个ASP.NET站点在一个IIS服务器上运行,当然使用不同的端口。这些站点允许通过表单身份验证登录。会话状态存储在本地状态服务器上。我的问题是,当用户登录到一个站点然后导航到另一个站点时,他们从第二个站点获得例外,并且必须关闭/重新打开他们的Web浏览器才能访问它。我的猜测是来自第一个网站的cookie显示他们也登录了第二个网站(虽然我可能完全错了)。

I've tried a few things to fix it (which are probably dumb and have nothing to do with the problem, but I'm far from an ASP.NET expert) including: 1) giving the sites different cookie names in Web.config's sessionState tag, and 2) Moving the sites to different app pools, but the problem persists. Any help would be appreciated.

我已经尝试了一些方法来修复它(这可能是愚蠢的,与问题无关,但我远非ASP.NET专家),包括:1)在Web.config中为站点提供不同的cookie名称sessionState标记,以及2)将站点移动到不同的应用程序池,但问题仍然存在。任何帮助,将不胜感激。

1 个解决方案

#1


2  

I'd recommend setting up different domains for each site. If this is local, use the host file to route local.site1.com and local.site2.com to the correct place. Obviously you'll have to keep the port. Then you should be setting cookie with a different domain for each site and not causing the confusion.

我建议为每个网站设置不同的域名。如果这是本地的,请使用主机文件将local.site1.com和local.site2.com路由到正确的位置。显然你必须保留端口。然后你应该为每个站点设置一个不同域的cookie,不会造成混淆。

#1


2  

I'd recommend setting up different domains for each site. If this is local, use the host file to route local.site1.com and local.site2.com to the correct place. Obviously you'll have to keep the port. Then you should be setting cookie with a different domain for each site and not causing the confusion.

我建议为每个网站设置不同的域名。如果这是本地的,请使用主机文件将local.site1.com和local.site2.com路由到正确的位置。显然你必须保留端口。然后你应该为每个站点设置一个不同域的cookie,不会造成混淆。