Chrome on iPad not working with ASP.NET 4 Chrome on iPad not working with ASP.NET 4 google-chrome google-chrome

Chrome on iPad not working with ASP.NET 4


I experienced the same problem. Most everything works fine on my page, just a few items that are modified on the client side display incorrectly.

I inspected the header files that are returned from each browser on the ipad, and found that when in Chrome in Desktop mode, it was just pretending to be an a Mac Box, sending the following in the header: Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10_7_3)+AppleWebKit/534.53.11+(KHTML,+like+Gecko)+Version/5.1.3+Safari/534.53.10

and when it is in standard mode it sens the following in the header:Mozilla/5.0+(iPad;+CPU+OS+6_0+like+Mac+OS+X)+AppleWebKit/534.46.0+(KHTML,+like+Gecko)+CriOS/21.0.1180.82+Mobile/10A403+Safari/7534.48.3

I attempted to add a new browser to my "app_browsers" directory, copying "chrome" and re-naming it "chromeios", and replacing the "chrome" useragent inside with CriOS. This did nothing, and I am not even sure that the files in the "app_Browsers" directory are doing anything.

That's when I came across this question. The answers suggested by the users vamshik and Jay Douglass, when put together worked for me.

Jay's however was incorrect in that it has the wrong user agent (it should be "crios").

User geo1701 however complained about adding this to every page. This can easily be done by creating a class that inherits System.Web.UI.Page and then add above code with the "protected void Page_PreInit" event, and then replace the inheritance on each web page with your new class. Then if you ever need to add something that is needed in every page, you have that class to add it too.

I am also wondering if there is a way to add it to the global.asax class? but I am guessing not...

Still looking for a better solution. If I find one, I will update.

Found the following related posts:

Chrome for iOS user agent on iPad

ASP.NET Webforms Doesn't Render Postback JavaScript Function for Chrome/iOS

UPDATEI found this by Scott Hanselman. While he is talking about cookies, I think his suggestions may send us in the right direction.

OK! FINAL UPDATE!!!

After installing .NET Framework 4.5, and removing the files from my app_browsers directory, the Chrome on my iPad is working. I looked at the entries in the new .Browser files provided by .net 4.5, and there was nothing remarkable, so I am guessing that there was more too it then some updating to the the .browser files.

The .Net framework 4.5 can be downloaded here


ASP.NET may be incorrectly detecting Chrome on iPad as a "downlevel" browser that doesn't support JavaScript. ASP.NET uses the user agent string to detect down level browsers. To force Chrome to be detected as an "uplevel" browser, you can do this:

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


Below worked for me...

if (Request.UserAgent != null && Request.UserAgent.IndexOf("crios", StringComparison.OrdinalIgnoreCase) > -1){    this.ClientTarget = "uplevel";}