KNOWLEDGE BASE

Browsing your asp.net website on an iPhone using Chrome does not work


You have an Asp.Net 4.0 website that uses cookies. You are also using your iPhone and the new Chrome browser to access the website and you cannot login to the site correctly or navigate around it without bouncing back to the login page

Google has just released its new iPhone Chrome browser - it's really good, you should check it out although there is a slight problem when using it on your Asp.Net 4.0 websites that use cookies or have login functionality.

You will notice that when you browse to your site and say login, the cookie session id is now contained within the URL - wtf? Well this is basically because the User Agent string that Chrome is sending is not recognised by your website and by default, Asp.Net 4.0 is set to downgrade the browser to the lowest it knows about so assumes you cannot support cookies - this is why you see the cookie id in the url.

This has been recognised as a bug in Asp.Net 4.0 and is fixed in 4.5 where all browsers are now assumed to support cookies.

The fix is very simple, follow these steps to restore functionality to your sites:

Add a folder in your web project named App_Browsers (right-click the project, choose: Add > Add ASP.NET Folder > App_Browsers)
Add a file in that folder (right-click, choose: Add > New Item). The file can have any name, but must have the .browser ending. Usually there is a Form.browser in there so just modify that one
Add the following lines inside the <browser> element:

<capabilities>
<capability name="cookies" value="true" />
</capabilities>

Save and browse using your iphone - you should now see the site working as before

Credits for the above fixes go to the following urls where you can find more information about the browser files and how to use them:

http://msdn.microsoft.com/en-us/library/ms228122.aspx

http://stackoverflow.com/questions/4158550/problem-with-asp-net-forms-authentication-when-using-iphone-uiwebview

http://stackoverflow.com/questions/11324835/ipad-iphone-chrome-auth-cookie-not-setting-over-jquery-post-ajax-mvc-3


Need an Umbraco Master?

Here at Simon Antony, we have an in house certified Umbraco Grand Master available for hire. Got a problem with your site, need architecture advice, give us a call to speak to Simon directly and see how we can help

Contact Simon Today!