ASP.NET authentication cookies not stored when using jQueryMobile on iPad

房东的猫 提交于 2020-01-23 02:38:07

问题


I have an ASP.NET MVC2 app using jQueryMobile. It is a secure app, and i'm using the ASP.NET authentication within the MVC2 framework.

I am using standard authentication via the web.config:

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

I am securing certain controllers using the Authorize attribute:

[Authorize]
public class ClientController : Controller

All my web pages as based upon the same master page, which has a top-level container div as follows:

<div class="page" data-role="page">

It all works perfectly on Chrome. However, on the iPad the authentication does not work. It seems that the authentication cookie never gets stored on the client. The iPad keeps displaying the logon page, even if I type correct credentials. I have tried setting Safari Accept Cookies settings to 'Always' too.

Has anyone had any success deploying a jQueryMobile app using ASP.NET MVC2 authentication on an iPad? Thanks.

Edit: Ok, I have ascertained that the cookie is indeed being stored on the client, but it appears that jQueryMobile+Safari are somehow consipring to continually display the login page rather than redirecting me to the page that should be shown according to the logon redirect.


回答1:


I believe I have the answer. With regard to the iPad, you need to specifically set web.config to force the use of cookies. My authentication setting in web.config now looks like this:

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

It is the cookieless="UseCookies" entry that solved the problem. The default value for this is UseDeviceProfile. It must have been the case that an iPad does not have a consistent UseDeviceProfile regime. On the iPad, sometimes it worked, sometimes it didn't. Don't ask me why. It now seems to be consistently working.




回答2:


I agree with Journeyman, thats what I used. However if they add the website to the Homescreen, then these settings still do not work.

some have asserted they don't store the cookie in that case. see related Q: iPhone/iPad WebApps don't allow cookies?



来源:https://stackoverflow.com/questions/6212841/asp-net-authentication-cookies-not-stored-when-using-jquerymobile-on-ipad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!