Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a PhoneGap based app to authenticate against an ASP.NET Forms Authentication backend?

Has anyone managed to get ASP.NET Forms Authentication (with cookies) working with a PhoneGap based mobile application?

I have come across the following questions about managing cookies within PhoneGap and configuring the server properly:

  • Where cookie is managed in phonegap app with jquery?
  • https://github.com/phonegap/phonegap-iphone/issues/190
  • Asp.Net Forms Authentication when using iPhone UIWebView

But unfortunately neither of these solutions work. The requests coming from a PhoneGap application do not indicate an authenticated user even though when I run the same dashboard.html code as a file in Safari the requests show up as authenticated.

like image 473
Andrew Thompson Avatar asked Sep 23 '11 02:09

Andrew Thompson


People also ask

Where do you set authentication mode in ASP.NET application?

config file to implement the authentication of web application. Here we add Forms authentication mode and loginUrl is my login page where we create our login form and we also assign two users for authentication which is hard coded. So only two users by this name can authenticate our application page.

What is form authentication in ASP.NET with example?

Forms authentication enables user and password validation for Web applications that do not require Windows authentication. With forms authentication, user information is stored in an external data source, such as a Membership database, or in the configuration file for an application.

What are the authentication modes in ASP.NET for security?

ASP.NET supports Forms Authentication, Passport Authentication, and Windows authentication providers. The mode is set to one of the authentication modes: Windows, Forms, Passport, or None. The default is Windows. If the mode is None, ASP.NET does not apply any additional authentication to the request.


1 Answers

SOLUTION:

cookieless="UseCookies" in web.config FINALLY did it for me:

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

REF: https://groups.google.com/forum/?fromgroups#!topic/phonegap/Thj0fS2GDh4

like image 179
capdragon Avatar answered Oct 17 '22 21:10

capdragon