Monday, 24 December 2012

Fixing ASP.NET application for IE10 compatibility

We've a stable MVC web application. However, recently there was a sprung in issues (mostly JavaScript) breaking many of the existing features.
Recently, QA started to test application in IE10 browser after the analytic showing an increased traffic from it (Thanks to a lot of new Windows 8 devices). Where QA was quick enough to log defects one-after-the-another, we as a developer, were a bit panicked.

This post is all about fixing your application for IE 10. I'm in progress of fixing my application and will keep posting any new gimmick. (I appreciate if you could share your experiences too)

1st Fix (Master Stroke)

Issue: Application working in cookieless mode. I.e. Adding session to URL. For example:
upon login (Forms Authentication), http://mysite.com/welcome.aspx, it shows http://mysite.com/welcome.aspx(A(ikRoEoqwOieH_FyADedeEbit-_uDNadHNudahUar-HaUsU99DiasIadsjKAsjJiaojdJaJadijAQBR0))/Welcome.aspx


The first fix I did, was with minutest change but fixed more than 80% issues in one go. If you're using FormsAuthentication, you may find application running in CookieLess mode. I.e., when a user authenticates, there is a long dirty string that gets appended to brwoser for each request (as happened in our case)

FIX: You need to check for 2 things in web.config to ensure that your application doesn't switch to cookieless mode:

1. Add cookieless="UseCookies"  in your FormsAuthentication tag





2. Add cookieless="false" in Session Tag


2nd Fix: Forced to make application run in IE9 mode

There is a major issue (still unresolved) which forced me to apply a fix that forces IE10 to run in IE9 mode for my application.

ISSUE: JQuery $.Ajax POST request doesn't posts data which causes action methods to fail due to null arguments.


Searched a lot and found this issue raised by developers of different technologies - PHP, .NET etc. as it is a JQuery issue (http://bugs.jquery.com/ticket/12790)
Until this issue is resolved, I'm applying following hack:


@if (HttpContext.Current.Request.UserAgent!=null && HttpContext.Current.Request.UserAgent.ToLower().Contains("msie 10"))
{

}
else
{

}
   
This resolved all IE10 issues because it is now working IE9 mode when it is a IE10 browser.

No comments:

Post a Comment