Asp.Net使用iPhone的UIWebView时,窗体身份验证 [英] Asp.Net Forms Authentication when using iPhone UIWebView

查看:183
本文介绍了Asp.Net使用iPhone的UIWebView时,窗体身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个使用窗体身份验证一个Asp.net MVC 2应用程序,目前我的问候认证/登录在网上有我们的iPhone应用程序的一个问题。我们已经开发出使用了UIWebView的控制一个简单的iPhone应用程序。在这个阶段,所有的应用程序的作用是定位到我们的网站Asp.Net。简单吧?的问题是,用户无法得到过去的登录页面。该再现步骤是:

I am writing a Asp.net MVC 2 application that uses Forms Authentication and currently I am having a problem with our iPhone application in regards to the authentication/login over the web. We have developed a simple iPhone app that uses the the UIWebView control. At this stage, all the app does is navigate to our Asp.Net website. Simple, right? The problem is, that the user cannot get past the login page. The repro steps are:


  • 开启iPhone应用程序。

  • 的应用程序导航到主页。

  • 的用户没有通过验证,那么他们将被重定向到登录界面/页

  • 用户输入正确的用户名和密码。点击提交。

  • 在服务器端,所述用户被认证并生成一个cookie和使用FormsAuthentication.GetAuthCookie发送到客户端。

  • 服务器将被重定向到用户发送到正确的主页。

但随后将用户重定向的返回的登录屏幕!

But the user is then redirected BACK to the login screen!

我已经做了一些大量的调试就这个问题和我所知道的是:

I've done some extensive debugging on this and what I do know is:

该cookie被发送到客户端,而客户端存储的cookie。在iPhone调试器及使用Javsascript显示页面上的cookie数据验证了这一点。该cookie被发送回服务器。在Visual Studio调试验证了这一点。这是正确的cookie(它是被设置的相同)。该物业User.Identity.IsAuthenticated返回false出于某种原因,即使身份验证cookie被包含在Request对象。我已经验证了iPhone应用程序是安装程序接受Cookie,它们是在客户端上。

The cookie is being sent to the client, and the client is storing the cookie. Verified this in the iPhone debugger and also by using Javsascript to display cookie data on the page. The cookie is being sent back to the server. Verified this in the Visual Studio debugger. It is the correct cookie (it's the same one that was set). The property User.Identity.IsAuthenticated returns false for some reason, even though the auth cookie is contained in the Request object. I have verified that the iPhone app is setup to accept cookies, and they are on the client.

下面是有趣的事情:如果你打开​​iPhone上的Safari浏览器,并直接进入我们的网站,它工作正常。

Here is the funny thing: It works fine if you open the Safari browser on the iPhone and go to our site directly.

它在iPad相同的行为太它不会让过去的登录屏幕。这repros在仿真器和设备上。

It has the same behaviour on the iPad too in that it doesn't get past the login screen. This repros on the emulators, and on devices.

这同一个网站已经过测试IE 7-8,Safari浏览器(Windows版),黑莓,IEMobile 6.5 Phone 7和它的作品找到。唯一的情况下,它不工作就在iPhone应用程序中的一个UIWebView。

This same web site has been tested with IE 7-8, Safari (for Windows), Blackberry, IEMobile 6.5, Phone 7 and it works find. The only circumstance that it doesn't work on is the UIWebView in the iPhone app.

推荐答案

我们找到的解决方案是创建一个文件(generic.browser),并包括此XML来告诉web服务器Mozilla的,默认浏览器设置应该所有的Cookie。

The solution we found was to create a file (generic.browser) and include this xml to tell the web server that "Mozilla" and the Default browser settings should all support cookies.

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

这篇关于Asp.Net使用iPhone的UIWebView时,窗体身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆