通过子域 ASP.NET 进行表单身份验证
这个问题与此类似: Asp.net Profile Across Sub-Domain
我我基本上想知道如果用户通过“www.yourdomain.com”登录,“subdomain.yourdomain.com”是否也可以通过检查他们的 AuthCookie 来识别他们是否已登录?
所引用问题的答案是将: domain="yourdomain.com"
放入您的 web.config 中。
我的问题是,当您的域是 localhost 时,如何将其设置为在本地工作?您是否只是在本地/开发环境中取出域?
任何对此的帮助将不胜感激。
谢谢!
This question is similar to this: Asp.net Profile Across Sub-Domain
I'm basically wondering if a user logs in through "www.yourdomain.com", is it possible for "subdomain.yourdomain.com" to also recognize them as logged in by checking their AuthCookie?
The referenced question's answer is to put: domain="yourdomain.com"
within your web.config.
My question is how do you set this up to work locally when your domain is localhost? Do you just take domain out on your local/dev environment?
Any help with this would be much appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,我在过去的一个小时里刚刚编写了这样的代码。我在 Web.config 中使用了 httpCookies,尽管在表单身份验证标记上设置域也有效。
这是我在 web.config 中设置的内容:
这是我添加到主机文件中的内容:
然后,当我在开发盒上访问该网站时,我浏览到:
I actually just coded something up like this in the last hour. I used httpCookies in Web.config although setting the domain on the forms authentication tag works also.
Here's what I set in web.config:
Here's what I added to my hosts file:
Then when I access the site on my dev box I browse to:
好吧,localhost 只是 127.0.0.1 的本地 DNS 条目。
如果您编辑 c:\windows\system32\drivers\etc\hosts 文件,您可以添加其他条目,使其与您的实时环境匹配(但是,显然,这意味着对这些域的所有请求都将发送到您的本地计算机,而不是真正的服务器)。
如果您正在讨论跨应用程序的不同部署(本地、开发、发布)管理配置,那么您需要考虑执行一些构建后任务。
Well, localhost is just a local DNS entry for 127.0.0.1.
If you edit your c:\windows\system32\drivers\etc\hosts file, you can add other entries such that it matches your live environment (but, obviously, it will mean that all requests for those domains will go to your local machine, not the real servers).
If you're talking about managing configs across different deployments of your app (local, dev, release) then you need to look at doing some post-build tasks.