11

I just downloaded Google Chrome for iPad and I noticed that it doesn't work with ASP.NET 4 websites!

For example, create a simple page:

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

Protected Sub LinkButton1_Click(sender As Object, e As System.EventArgs)
    Response.Write("Link button was clicked")
End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
    </div>
    </form>
</body>
</html>

Now try clicking the Link Button, but it doesn't fire the postback event.

I can't seem to debug because there is no javascript console to find out what is going on.

!! UPDATE !!

I found that you need to select Request desktop site from the settings drop down menu in Chrome to get it to work.

!! UPDATE !!

ASP.NET does not recognize the most current versions of some browsers, and will consequently treat them as down-level browsers. (Basically: no JavaScript.) The fix is to get updated browser-definition files.

Where can we get an updated browser-definition file for Chrome?

George Filippakos
  • 16,359
  • 15
  • 81
  • 92
  • asp.net have nothing to do with client browsers - browsers did not know what is behind the server they just read html. – Aristos Jul 21 '12 at 12:19
  • it's the code that is auto generated for postback events that is causing problems. It's probably googles fault - maybe a bug with their ipad browser when not in 'desktop site mode' (whatever that is). – George Filippakos Jul 23 '12 at 12:04
  • I use only google chrome and did not have any issue with very difficult programs. – Aristos Jul 23 '12 at 13:53
  • This is question is specific to the google chrome browser for the iPad on iOS. – George Filippakos Jul 23 '12 at 14:50
  • Have you tried to get sites developed on other kind of web framework in this browser? I am pretty sure that you will receive same result. Looks like that it is browser specific. – RredCat Oct 06 '12 at 13:40

4 Answers4

8

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

UPDATE I 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

Community
  • 1
  • 1
Rootberg
  • 131
  • 1
  • 6
1

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";
    }
}
Jay Douglass
  • 4,828
  • 2
  • 27
  • 19
1

Below worked for me...

if (Request.UserAgent != null && Request.UserAgent.IndexOf("crios", StringComparison.OrdinalIgnoreCase) > -1)
{
    this.ClientTarget = "uplevel";
}
Spectre87
  • 2,374
  • 1
  • 24
  • 37
vamshik
  • 11
  • 1
0

It's likely ASP.NET generates invalid page.

I don't know about iPhone, but Android version has Remote Debugging. You can try inspect page there.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
bvs
  • 1