Click here to Skip to main content
12,550,449 members (45,342 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked

Mobile Device Browser File

, 8 Jul 2010 Ms-PL
Rate this:
Please Sign up or sign in to vote.
Mobile Device Browser File

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.


This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


About the Author

Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMobile Detection Pin
Amimpat15-Nov-10 15:16
memberAmimpat15-Nov-10 15:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161021.1 | Last Updated 8 Jul 2010
Article Copyright 2010 by matt-dot-net
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid