ASP.NET AJAX 将被禁用的原因

Reasons why ASP.NET AJAX would be disabled(ASP.NET AJAX 将被禁用的原因)

本文介绍了ASP.NET AJAX 将被禁用的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 ASP.NET AJAX 和 AJAX Control Toolkit 的 ASP.NET 应用程序.该应用程序在 PC 上的所有最新浏览器上运行良好.它在我的 iPad 上也能正常工作,至少在第一次访问应用程序时是这样.我发现如果我关闭 iPad 并稍后返回该页面(通过书签或类似方式),该站点就会损坏.我已将故障范围缩小到 ASP.NET/ASP.NET AJAX 问题/错误/限制,我正在寻找一些帮助以取得进展.

I have an ASP.NET application that uses ASP.NET AJAX and the AJAX Control Toolkit. The application runs fine on all recent browsers on a PC. It also works fine on my iPad, at least the first time the application is accessed. I have found that if I shut down the iPad and return to the page later (via a bookmark or similar), the site is broken. I have narrowed down the failure to an ASP.NET/ASP.NET AJAX issue/bug/limitation, and I'm looking for some help to progress.

使用 Fiddler 作为 iPad 的代理服务器,我在重新打开页面时发现了以下问题.

Using Fiddler as a proxy server for the iPad, I have identified the following problems, when re-opening the page.

  1. 我的 *.skin 文件没有正确应用.生成的样式标签根本不包括在 *.skin 文件中指定的一些参数.
  2. 该页面不包含 MicrosoftAjaxWebForms.js 文件.(工作时,它会在所有 ToolkitScriptManager 脚本的正上方发出对 ScriptResource.axd 的引用.
  3. 该页面不包含对另一个以函数 WebForm_FindFirstFocusableChild(control) 开头的 js 文件的引用
  4. 该页面不包含一些隐藏字段,例如 __LASTFOCUS、__EVENTTARGET 和 __EVENTARGUMENT
  5. 该页面不包含使用 document.forms['aspnetForm'] 和定义 __doPostBack 的脚本块.
  6. 页面不包含执行 Sys.WebForms.PageRequestManager._initialize 的脚本块
  7. 其他一些初始化脚本不存在(设置焦点、创建 updateprogress 等)

不知何故,框架似乎决定它不需要这些脚本并且不发出它们.鉴于所有脚本都是相互关联的,因此必须有一个共同的原因.这可能与不包含 *.skin 属性的原因有关.有任何想法吗?我会考虑浏览器功能,但这只会发生在后续访问该站点时,而不是第一次访问时.

Somehow, it appears the framework decides that it isn't doesn't need these scripts and doesn't emit them. Given all the scripts are interrelated, there must be a common reason. This may be related to the reason that the *.skin properties are not included. Any ideas? I would have thought about browser capabilities, but this only happens on subsequent visits to the site, not the first.

绝对看起来像浏览器功能问题.

Definitely looking like a browser capability issue.

有效的请求:用户代理:Mozilla/5.0(iPad;U;CPU OS 4_3_3,如 Mac OS X;en-us)AppleWebKit/533.17.9(KHTML,如 Gecko)Version/5.0.2

Requests that work: User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2

不会的请求:用户代理:Mozilla/5.0(iPad;U;CPU OS 4_3_3,如 Mac OS X;en-us)AppleWebKit/533.17.9(KHTML,如 Gecko)Mobile/8J2

Requests that don't: User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8J2

将尝试在 App_Browsers 中创建一个自定义文件并回传额外信息.

Will attempt creating a custom file in App_Browsers and post back with extra info.

推荐答案

根本问题确实是 ASP.NET 将 iPad 识别为通用下层Mozilla"而不是 Safari,当应用程序以全屏方式加载时模式.它认为不支持 JavaScript,等等.

The root issue is indeed ASP.NET recognizes the iPad as a generic downlevel 'Mozilla' instead of Safari, when the application is loaded in full screen mode. It thinks JavaScript is not supported, etc.

解决方案是将以下内容添加到所有 ASP.NET 页面(通过将其添加到所有 ASP.NET 页面派生自的基本页面).

The solution is adding the following to all of your ASP.NET pages (by adding this to the base page all your ASP.NET pages derive from).

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

(我尝试创建一个 *.browser 文件,但失败了,因为它似乎无法从我自己的内部引用框架的 *.browser 文件.)

(I tried creating a single *.browser file but failed miserably as it doesn't appear I can reference the framework's *.browser files from within my own.)

这篇关于ASP.NET AJAX 将被禁用的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:ASP.NET AJAX 将被禁用的原因

基础教程推荐