ASP.NET Ajax回发突然停止在IPhone / IPad上

我有一个Asp.Net 4.0网站/控制界面,它使用更新面板和一些按钮.更新面板连接到每5秒执行一次的计时器,导致部分回发.按钮切换一些设置,然后通过类似于此的调用强制更新更新面板:
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm._doPostBack('<%= UpdatePanel.ClientID %>','');
return true;

该网站在IE / Firefox和Safari移动设备(IPhone / IPad)上运行良好,但在移动设备上,回发随机且无声地停止工作.我认为这可能与节省电池有关,并且safari在空闲时关闭部分回发.问题是,当用户返回到站点时,回发完全关闭,定时器和按钮都不会导致任何回发. (我已监控服务器上的网络流量以验证这一点).即使用户刷新网站(多次),部分回发也会重新发挥作用.它只是停止向服务器发布数据.然后突然,没有特别的原因,回发开始再次工作.停机时间通常长达10分钟,这完全使我的网站无法用于其目的.

鉴于在回发开始之前需要很长时间,我想知道在客户端或IIS中是否有任何设置可以使用?

该网站将仅在我的客户设备上运行,而不是公开的,所以如果在客户端上有任何设置可以使用,我就是为了它.

我对此感到很困惑,并没有找到触发“bug”的方法,有时会发生这种情况.任何建议和提示都非常感谢.

更新:

添加了一些错误处理,当回发失败时,我(不一致)收到以下消息:

The page is performing an async postback but the ScriptManager.SupportParialRendering property is set to false. Ensure that the property is set to true during postback.

很可能这个属性对于第一个实例中的设备显然是正确的,否则回发将永远不会工作,但实际情况并非如此.

更新2:
找到以下博客文章,建议更改web.config中的browserCap设置.现在试试这个.会报告回来.其他建议仍然受到欢迎.
ASP.NET 4 BrowserCaps (or: what were they thinking?)

以上在全屏模式下(从主屏幕运行)禁用safari mobile中的javascript.以下文章建议修复此问题.
Gotcha: iPad versus ASP.NET

解决方法

我的问题中“更新2”下的调查结果解决了这个问题.显然,Safari UserAgents偶尔会被识别为Mozilla 0.0,如以下博文中所述: ASP.NET 4 BrowserCaps (or: what were they thinking?)

The first WTF is that the .NET framework actually throws an exception if it detects an async postback from a browser that according to browserCaps does not support async postback. It’s as if they think they kNow best who is capable of async postbacks even with overwhelming evidence to the contrary…

The next WTF was substantially harder to find. Why are Safari UserAgents occasionally recognized as Mozilla 0.0 and why was I never able to reproduce the issue even when using a UserAgent string that I just copied from an exception?

The answer lies in

<browserCaps userAgentCacheKeyLength="64" />

The default setting for the user agent cache key length is to take the first 64 characters of the UserAgent string. …

页面下方:

Setting the userAgentCacheKeyLength to 256 solved the problem,even though there are still UserAgent strings out there that are identified as Mozilla 0.0. At least Now it’s consistent.

所以,把< browserCaps userAgentCacheKeyLength =“256”/>在Web.Config解决了这个问题.

不幸的是,当在全屏模式下使用safari浏览器时(主屏幕上保存的链接),这会导致另一个问题.在全屏模式下,Safari使用不同的HTTP用户代理字符串,而ASP.NET不再将浏览器识别为Safari,而是将其识别为没有功能的通用浏览器,例如JavaScript和JQuery将停止工作.在Gotcha: iPad versus ASP.NET进一步详细说明.解决方案是在每个网站上的Page_Init中添加以下内容.不是很优雅,但它与上面的一起工作:

protected void Page_PreInit(object sender,EventArgs e)
{
   if (Request.UserAgent != null && Request.UserAgent.IndexOf("AppleWebKit",StringComparison.CurrentCultureIgnoreCase) > -1)
   {
      this.ClientTarget = "uplevel";
   }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“WPF...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这...
Some samples are below for ASP.Net web form controls:(from http://www.visualize.uk.com/resources/asp
问题描述: 对于未定义为 System.String 的列,唯一有效的值是(引发异常)。 For columns not defined as System.String, the only vali
最近用到了CalendarExtender,结果不知道为什么发生了错位,如图在Google和百度上找了很久,中文的文章里面似乎只提到了如何本地化(就是显示中文的月份)以及怎么解决被下拉框挡住的问题,谈
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence changed a lot since 1.1. Here is the order: App
静态声明: &#39; Style=&quot;position: relative&quot; AppendDataBoundItems=&quot;True&quot;&gt; (无 或 空 或
以下内容是从网络上搜集资料,然后整理而来的。不当之处,请不吝指教。(The following were from network, and edited by myself. Thanks in a
Imports System Imports System.Reflection Namespace DotNetNuke &#39;*********************************
Ok so you have all seen them: “8 million tools for web development”, “5 gagillion tools that if you
以下内容来源于: http://blog.csdn.net/cuike519/archive/2005/09/27/490316.aspx 问:为什么Session在有些机器上偶尔会丢失? 答:可能和
以下文章提到可以用“http://localhost/MyWebApp/WebAdmin.axd”管理站点: ---------------------------------------------
Visual Studio 2005 IDE相关的11个提高开发效率的技巧 英文原创来源于: http://www.chinhdo.com/chinh/blog/20070920/top-11-vis
C#日期格式化 from: http://51xingfu.blog.51cto.com/219185/46222 日期转化一 为了达到不同的显示效果有时,我们需要对时间进行转化,默认格式为:2007
from: http://www.nikhilk.net/UpdateControls.aspx Two controls that go along with the UpdatePanel and
Open the report in the Designer. In the ToolBox, select/expand the &quot;Report Items&quot; section.
from: http://drupal.org/node/75844 Do this: find which TinyMCE theme you are using. For the sake of
asp.net中给用户控件添加自定义事件 用户控件中定义好代理和事件: public delegate void ItemSavedDelegate(object sender, EventArgs
在Windows版本的Safari中浏览以下的页面。 http://www.asp.net/AJAX/Control-Toolkit/Live/Calendar/Calendar.aspx Calen
http://aspnet.4guysfromrolla.com/articles/021506-1.aspx By Scott Mitchell Introduction When creating