开发者

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

开发者 https://www.devze.com 2023-04-07 12:37 出处:网络
Has anyone managed to get ASP.NET Forms Authentication (with cookies) working with a PhoneGap based mobile application?

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 开发者_如何学JAVAa file in Safari the requests show up as authenticated.


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


If you're creating a cookie in a phonegap app, you're basically creating a cookie for the localhost. When you go out to the .net server, that server can't see that cookie.

This is very general, but I hope that this helps a little?


You may use in web.config , cookieless="UseCookies" in authentication tag


As I don't know your requirements, this may be a silly answer, but, why you don't consider in this case to deliver the functionality not from a ASP.NET service but from a WCF/Service Stack service?

I'm currently working also in a PhoneGap application but it is served by a REST web service (Service Stack) and I think this kind of architecture offers a lot of flexibility.

0

精彩评论

暂无评论...
验证码 换一张
取 消