We are using the Mobile Device Browser File from codeplex on our SharePoint publishing portal to detect mobile devices in combination with a simple HTTP Module to redirect them to our mobile site. This works well and as long as we are diligent with getting the latest version of the MDBF, we should be on top of new devices/browsers. The MDBF currently defines over 60 distinct capabilities of about 400 different devices. Of those capabilities, we are really only interested in the isMobileDevice value. However, many of the other capabilities directly affect the behavior of ASP.Net when a particular browser is detected. The preferredRenderingMime capability tells ASP.Net what content type should be sent as a response header. So in the case of a browser that prefers XHTML, and is not a mobile device and therefore not redirected, ASP.Net obliges by setting the response content type. Unfortunately the markup coming from our SharePoint portal does not meet the standards of XHTML and causes those browsers to break. We noticed this when we added web slices to the portal and saw that the Windows-RSS-Platform User-Agent was being sent the Content-Type: application/xhtml+xml header. To fix the issue we added a new browser entry that matched the Windows-RSS-Platform user agent and set the preferredRenderingMime to text/html and at the same time defined some other user agents that we expected to have the same problem. Unfortunately this approach makes being diligent with keeping the latest file from the MDBF team more difficult. With so many devices we may easily miss some that prefer the XHTML markup but are not mobile devices.
To solve the problem, I created a very simple (4 lines) HttpModule that Handles the HttpApplication.PostRequestHandlerExecute event and in the case of Response.ContentType==”application/xhtml+xml” sets the ContentType to “text/html”. This will make it much easier to maintain the MDBF and take care of any other unknown agents.