在本地IIS跨子域Forms身份验证 [英] Forms Authentication across Sub-Domains on local IIS

查看:285
本文介绍了在本地IIS跨子域Forms身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一个cookie可以在使用设置多个子域共享

I know a cookie can be shared across multiple subdomains using the setting

<forms 
    name=".ASPXAUTH" 
    loginUrl="Login/" 
    protection="Validation" 
    timeout="120" 
    path="/"     
    domain=".mydomain.com"/>

在Web.config中。但如何复制本地机器上同样的事情。我使用Windows 7和我的笔记本电脑IIS 7。所以,我有网站localhost.users /我的现场实际users.mysite.com
localhost.host/~~V为host.mysite.com和类似。

in Web.config. But how to replicate same thing on local machine. I am using windows 7 and IIS 7 on my laptop. So I have sites localhost.users/ for my actual site users.mysite.com localhost.host/ for host.mysite.com and similar.

推荐答案

localhost.users localhost.host 是跨域。 Cookie不能共享跨域。

localhost.users and localhost.host is cross domain. Cookies cannot be shared cross domain.

这样子域名不同,但根域你可以这样配置保持不变:

You could configure it like this so that the sub-domain differs but the root domain stays the same:


  • users.localhost

  • host.localhost

  • users.localhost
  • host.localhost

现在设置你的web.config中的cookie域本地主机

Now set the cookie domain in your web.config to localhost:

domain=".localhost"

和在 C:\\ WINDOWS \\ SYSTEM32 \\ DRIVERS \\ ETC \\主机文件中添加以下2项:

and in your c:\Windows\System32\drivers\etc\hosts file add the following 2 entries:

127.0.0.1 users.localhost
127.0.0.1 host.localhost

现在,您将能够成功地共享之间的身份验证cookie users.localhost host.localhost

Now you will be able to successfully share the authentication cookie between users.localhost and host.localhost.

啊,不要忘了把你的自动化构建过程中的一步,将在生产发货前你的web.config值转换为正确的根域。

Ah, and don't forget to put a step in your automated build process that will transform your web.config value to the correct root domain before shipping in production.

这篇关于在本地IIS跨子域Forms身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆