ASP.NET Ajax postback suddenly stops on IPhone / iPad

I have an Asp.Net 4.0 website / management interface that uses the update panel and some buttons. The update panel connects to a timer that runs every 5 seconds, which results in a partial postback. The buttons toggle some options, and then force update the update panel with a call like this:

var prm = Sys.WebForms.PageRequestManager.getInstance(); prm._doPostBack('<%= UpdatePanel.ClientID %>', ''); return true; 

The site works great on IE / Firefox and on Safari mobile devices (IPhone / iPad), but on mobile devices there’s a random and silent stop. I believe that this may be due to battery saving, and that safari disables partial reverse gear when it is in standby mode. The problem is that when the user returns to the site, postback is completely disabled, and neither the timer nor the button causes any postbacks anymore. (I checked the network traffic on the server to check this). Even when the user updates the site (several times), a partial postback is returned. It just stops sending data to the server. Then, suddenly and without any specific reason, postback starts working again. Downtime is often up to 10 minutes, which completely makes my site useless for its purpose.

Given that it takes so long before the postback starts again, I wonder if there are any settings on the client side or in IIS for playback?

The website will only work on my client devices, it is not publicly accessible, therefore, if there are any settings for working with the client, I am for it.

I really got confused about this and did not find a way to cause an “error”, it just happens sometimes. Any advice and advice is greatly appreciated.


Update:

Some error handling has been added, and I (not sequentially) receive the following message when feedback fails:

The page performs asynchronous feedback, but the ScriptManager.SupportParialRendering property is false. Make sure the property is set to true during postback.

Oddly enough, this property is obviously true for the device in the first case, otherwise postback will never work, which is not the case.


Update 2: Found the following blog post suggesting changing the browserCap setting in web.config. Try it now. Will report. Other suggestions are still welcome. ASP.NET 4 BrowserCaps (or: what were they thinking?)

The above disables javascript in the safari mobile in full screen mode (works from the main screen). The following article suggests fixing this problem. Gotcha: iPad vs ASP.NET

+7
source share
1 answer

The results under “update 2” in my question solve the problem. Apparently, Safari UserAgents users are sometimes recognized as Mozilla 0.0, as indicated in the following blog post: ASP.NET 4 BrowserCaps (or: what were they thinking?) :

The first WTF is that the .NET platform actually throws an exception if it detects an asynchronous postback from a browser that, according to BrowserCaps, does not support async postback. As if they think they know better who is capable of asynchronous callbacks even with overwhelming evidence to the contrary ...

The next WTF was much harder to find. Why are Safari UserAgents sometimes recognized as Mozilla 0.0 and why have I never been able to reproduce the problem even when using the UserAgent string that I just copied from the exception?

The answer lies in

<browserCaps userAgentCacheKeyLength="64" />

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

And further on the page:

Setting userAgentCacheKeyLength to 256 solved the problem, although there are still UserAgent strings that are defined as Mozilla 0.0. At least now he's consistent.

So, putting <browserCaps userAgentCacheKeyLength="256" /> in Web.Config solves the problem.


This, unfortunately, causes another problem when the safari browser is used in full screen mode (the link is saved on the main screen). In full-screen mode, Safari uses a different HTTP User Agent String, and ASP.NET will no longer recognize the browser as Safari, instead it will recognize it as a shared browser without any features, and, for example, JavaScript and JQuery will stop working. Further developed in Gotcha: iPad vs ASP.NET . The solution is to put the following on each page on the Page_Init page. Not very elegant, but it works along with the above:

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

All Articles