使用iOS上的Google Chrome浏览器在ASP.NET网站上进行FormsAuthentication

A few people have said that they have noticed problems the new iPhone/iPad Google Chrome apps as well as trouble with applications that use hosted Safari inside of UIWebView (which is what Chrome is) or apps that host a website in PhoneGap. If you're using FormsAuthentication (in WebForms or MVC, doesn't matter) then Google Chrome for iOS might switch FormsAuth to Cookieless mode, which sucks for everyone.

少数人说,他们注意到新的iPhone / iPad Google Chrome应用程序出现问题,以及在UIWebView(Chrome即为Chrome浏览器)中使用托管Safari的应用程序或在PhoneGap中托管网站的应用程序出现问题。 如果您使用的是FormsAuthentication(在WebForms或MVC中无关紧要),则iOS的Google Chrome可能会将FormsAuth切换为无Cookie模式,这对所有人来说都很糟糕。

This has been fixed in .NET 4.5 and you won't see this problem if you have .NET 4.5 installed, even if you're running a .NET 4 application. For example, Bing.com is running .NET 4 applications under .NET 4.5 RC and wouldn't see this. If you install 4.5 (now or later) ASP.NET will always assume clients support cookies.

.NET 4.5中已修复此问题,即使您正在运行.NET 4应用程序,如果安装了.NET 4.5,也不会出现此问题。 例如,Bing.com在.NET 4.5 RC下运行.NET 4应用程序,并且看不到此内容。 如果安装4.5(现在或更高版本),ASP.NET将始终假定客户端支持cookie。

If you want to tell ASP.NET 4.0 or earlier that EVERY browser supports cookies for FormsAuth you can do ONE of these things:

如果你想告诉ASP.NET 4.0或更早版本,每一个为FormsAuth浏览器支持Cookie,你可以做的这些东西

1.为您的应用程序(或计算机)更改Generic.Browser (1. Change Generic.Browser for your app (or machine))

Make a file called generic.browser in a folder called App_Browsers and put this in it:

在名为App_Browsers的文件夹中创建一个名为generic.browser的文件,并将其放入其中:

<browsers>
<browser refID="GenericDownlevel">
<capabilities>
<capability name="cookies" value="true" />
</capabilities>
</browser>
</browsers>

2.在您的web.config中强制Cookieless = UseCookies (2. Force Cookieless=UseCookies in your web.config)

Add cookieless="UseCookies" for your forms element in web.config.

在web.config中为表单元素添加cookieless =“ UseCookies”。

<authentication mode="Forms" >
<forms loginUrl="~/Account/LogOn" timeout="2880" cookieless="UseCookies" />
</authentication>

Hope this helps.

希望这可以帮助。

相关链接 (Related Links)

翻译自: https://www.hanselman.com/blog/formsauthentication-on-aspnet-sites-with-the-google-chrome-browser-on-ios

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值