简体   繁体   English

ASP.NET Forms身份验证-Chrome和Firefox上的单点登录问题

[英]ASP.NET Forms authentication - Issue with single sign-on on Chrome and Firefox

We have two ASP.NET v4.0 websites on same domain (two different virtual directories) and we plan to use forms authentication single sign-on between them. 我们在同一域(两个不同的虚拟目录)上有两个ASP.NET v4.0网站,我们计划在它们之间使用表单身份验证单点登录。

To support single sign-on using forms authentication we are using same settings for forms authentication and machine key in web.config for both websites (as shown below). 为了支持使用表单身份验证的单点登录,我们在两个网站的web.config中对表单身份验证和机器密钥使用了相同的设置(如下所示)。

<authentication mode="Forms">
<forms loginUrl="Login.aspx" slidingExpiration="true" timeout="28800" defaultUrl="Default.aspx" name=".MYAUTH"/>
</authentication>


<machineKey validationKey="xxxx" decryptionKey="yyy" validation="SHA1"/>

Single sign-on works on our local and QA environment on all browsers and also works on IE 9/10 on our staging server but for some weird reason does not work only on Firefox (v25) and Chrome (v31) on staging server. 单一登录可以在所有浏览器的本地和QA环境中使用,也可以在登台服务器上的IE 9/10上运行,但由于某些奇怪的原因,仅在登台服务器上的Firefox(v25)和Chrome(v31)上无法使用。 After logging in to first website when user is redirected to second website the forms authentication cookie is always null and user has to re-login. 登录到第一个网站后,将用户重定向到第二个网站后,表单身份验证cookie始终为空,用户必须重新登录。

I tried all suggested solutions (like setting the same path and domain name etc for forms authentication node in both web.config) but none of them helped. 我尝试了所有建议的解决方案(例如在两个web.config中为表单身份验证节点设置相同的路径和域名等),但是它们都无济于事。

My staging server is something like "ab-cd-ef.my.company.com" (notice multiple periods and hyphens in the server name). 我的登台服务器类似于“ ab-cd-ef.my.company.com”(请注意服务器名称中的多个句点和连字符)。 Has it got anything to do with the server name? 与服务器名称有关吗? I tried below combinations (none worked): 我尝试了以下组合(无用):

  1. <forms loginUrl="Login.aspx" slidingExpiration="true" timeout="28800" defaultUrl="Default.aspx" name=".MYAUTH" domain=".my.company.com"/>

  2. <forms loginUrl="Login.aspx" slidingExpiration="true" timeout="28800" defaultUrl="Default.aspx" name=".MYAUTH" domain=".company.com"/>

  3. <forms loginUrl="Login.aspx" slidingExpiration="true" timeout="28800" defaultUrl="Default.aspx" name=".MYAUTH" domain="ab-cd-ef.my.company.com"/>

This think is killing me now. 这种想法现在正在杀死我。 Any help would be highly appreciated. 任何帮助将不胜感激。

As weird it may seem, this problem was solved after I restarted the server. 看起来很奇怪,重新启动服务器后此问题已解决。

It now works without specifying domain in forms authentication setting in web.config (as both websites are on same server/domain with just different virtual directories). 现在,它无需在web.config的表单身份验证设置中指定域即可工作(因为两个网站都位于具有不同虚拟目录的同一服务器/域上)。

Defies any logic. 违反任何逻辑。 I hope it helps someone scratching his/her head. 我希望它可以帮助某人挠头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM