2

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.

Journeyman
  • 9,339
  • 14
  • 73
  • 121

2 Answers2

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.

Journeyman
  • 9,339
  • 14
  • 73
  • 121
0

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?

Community
  • 1
  • 1
Quincy
  • 1,600
  • 11
  • 18