窗体身份验证在本地IIS
我知道一个cookie可以在使用多个子域共享的设置窗体身份验证在本地IIS
<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/为host.mysite.com和类似。
localhost.users
和localhost.host
是跨域。 Cookie不能跨域共享。
,这样子域名不同,但根域你可以这样配置它保持不变:
users.localhost
host.localhost
现在设置Cookie域在您的网页.config至localhost
:
domain=".localhost"
并在c:\Windows\System32\drivers\etc\hosts
文件中添加下列2项:
127.0.0.1 users.localhost
127.0.0.1 host.localhost
现在,您将能够成功地共享users.localhost
和host.localhost
之间的身份验证cookie。
嗯,不要忘了在自动构建过程中采取一步,在生产中发货之前,您的web.config值将转换为正确的根域。
这是对运行在Framework 4.5中并尝试与框架4和更低级别共享令牌的人的提醒,请注意,这会导致您不会在4个或更低应用程序的任何一个上收到auth cookie。即:如果在你的web.config
您有:
<httpRuntime maxRequestLength="80480" targetFramework="4.5" />
你可以得到它通过移除targetFramework="4.5"
属性来得到它的工作的工作,虽然我不知道是否有任何副作用,这样做:
<httpRuntime maxRequestLength="80480" />
这节省了我在一对使用.NET 4.5.1的网站! –
我无法在子应用程序上进行身份验证。它在2个web.config文件中与targetFramework =“4.5”一起工作。谢谢 – Troopers
感谢Darin,在Visual Studio中创建这些网站时,如何在IIS中进行设置。 – Parminder
@Parminder,IIS配置问题应该在http://serverfault.com上讨论。 –
达林,谢谢,我在那里问过这个问题,但是在两个不同的地方问同样的问题是否有意义。 – Parminder