Asp.net表单身份验证Cookie问题 [英] Asp.net Forms Authentication Cookie Issue

查看:156
本文介绍了Asp.net表单身份验证Cookie问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发布到Azure中的登台服务器时,我遇到了一个奇怪的问题.在此部署中,我有一个使用SQL成员资格的Web应用程序.当我尝试通过登录页面登录时,我被重定向回登录页面.这是一个.NET 4.0应用程序.

I am running into a weird issue when publishing to a staging server in Azure. Within this deployment I have a single web application using SQL membership. When I attempt to log in via my login page I am redirected back to the login page. This is a .NET 4.0 application.

使用Firebug的网络面板,我可以看到当我按下Enter键时,表单就被张贴了,并且响应头具有我的身份验证票证的set-cookie属性.它显示两次.

Using Firebug's network panel I can see that when I hit enter the form is posted and the response header has a set-cookie attribute for my authentication ticket. It shows up twice.

.ASPXAUTHTEST=27D254F0AEEACB.........; domain=cloudapp.net; expires=Thu, 05-Jun-2014 05:29:24 GMT; path=/; HttpOnly

发布表单后,将设置cookie,并且在Firebug中看到重定向到默认URL的信息.当我点击默认URL时,该cookie不存在,因此我立即注销了.

When the form is posted the cookie is set and I see in Firebug that I redirected to my default URL. When I hit the default URL the cookie isn't present so I'm logged off immediately.

这是我正在使用的配置.

This is the configuration I am using.

<authentication mode="Forms">
      <forms cookieless="UseCookies" enableCrossAppRedirects="false" loginUrl="~/Default.aspx" name=".ASPXAUTHTEST" slidingExpiration="true"
        timeout="360" requireSSL="true" defaultUrl="~/Application/Index.aspx" protection="All" path="/" domain="cloudapp.net"/>
</authentication>

奇怪的是,我在Production中具有相同的部署,并且可以正常工作.我尝试再次重新部署整个实例(新VM等).这没有用.我还考虑过部署到新的OS版本,但这没用.

The weird thing is that I have the same deployment in Production and it works correctly. I have tried re-deploying the entire instance again (new VM etc). This hasn't worked. I also tried deploying to a new OS version thinking but that didn't work.

我添加了一些日志记录代码以查看发生了什么,但这使我得出与Firebug相同的结论,即未在浏览器中设置cookie.它与浏览器无关,因为我也尝试过Chrome和IE.

I have added some logging code to see what is happening but it leads me to the same conclusion as Firebug, the cookie is not being set in the browser. It's not browser related as I have tried Chrome and IE as well.

我最近从Azure SDK 1.6升级到了2.1.

I recently upgraded from Azure SDK 1.6 to 2.1.

有人有什么建议吗?

推荐答案

经过进一步的研究,我认为原因可以归因于Mozilla的公共后缀列表"以及使用它们在某些域上限制Cookie的浏览器.该网站可以在IE和Safari上运行.

After further research I believe the cause can be attributed to Mozilla's Public Suffix List and the browsers that use them to restrict cookies on certain domains. The site worked on IE and Safari.

当我改变时:

domain="cloudapp.net"

domain="{guid}.cloudapp.net"

它适用于所有浏览器.

StackOverflow响应进行了总结.

This StackOverflow response summarizes it.

您还可以访问公共后缀列表网站.

这篇关于Asp.net表单身份验证Cookie问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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