How to identify a mobile browser and direct relevant content to it?

I read that its bad (not recommended) to use User Agent Sniffing to send the right content for a mobile browser, so I'm wondering what is the best way to do this?

I use ASP.NET MVC and I created my site and it works well on desktop browsers, so I want to start creating a mobile version. When a mobile browser arrives on my site, I would like to use a different set of views, which ideally has the following attributes:

  • Link to pre-scaled images
  • Use minimal javascript
  • Delete all but main content

My first thought was to sniff the user agent and then send another .CSS file, but as stated above, I read that this is a bad way to do this, so I ask you for my thoughts.

+6
asp.net-mvc mobile mobile-website
source share
4 answers

A user agent is all that you have in your HTTP GET , but you must let someone else keep this list. We use the Microsoft Browser File with a custom view engine in much the same way as this post by Scott Hanselman .

+7
source share

The best way to discover a mobile browser is to use this wonderful Codeplex project:

http://mdbf.codeplex.com/

For information on how to create target views, read here:

http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx

+2
source share

The simplest approach may be to use a separate domain "m.yourdomain.com" or "yourdomain.mobi" ( Source ) so you can assume that the user is on a mobile device.

+1
source share

While I believe that he frowned to sniff the browser to determine the features, and you should use sniffing features like JQuery.support . When it comes to actually presenting significantly different layouts, I think you need to sniff the browser id and act accordingly.

0
source share

All Articles