Sys.WebForms is undefined on iPad

Is your site working perfectly fine everywhere except as an iPad full-screen application?  Is it giving you a “Sys.WebForms” is undefined error in javascript? Or is it acting like ajax is disabled in some other way?

This was an incredibly difficult problem to track down, so I thought I’d share it here to pass on the knowledge.

In my case, I was using Telerik’s RadScriptManager, but later I found it wasn’t limited to Telerik’s controls, but to any ajax-related code.  However, I point out Telerik in particular because on their forums they offered a dozen solutions that led me in the wrong direction.

The root problem is that the iPad full-screen app gives a user-agent header that ASP.Net does not recognize, so it believes that the browser does not support ajax.  This results in the ScriptManager not including “MicrosoftAjaxWebForms.js” and all sort of other things related to ajax panels not loading.

So the solution is to tell ASP.Net that the user-agent in question does support ajax.  Luckly we have a custom base page for all of our ASPX files, so I only had to add this in one place:

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

    base.OnPreInit(e);
}

I found this solution here.  Thank you! http://blog.lavablast.com/post/2011/05/29/Gotcha-iPad-versus-ASPNET.aspx#comment

1 comment so far

  1. David Homer on

    Hi thanks for the answer this solved it however we found it easier to add the supportsCallback to the browser definition file, documented here

    http://david-homer.blogspot.co.uk/2015/08/aspnet-ajax-doesnt-work-on-iphone-or.html


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: