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.
CodeProject
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.