MVC4 mobile support and browser capabilities

Discussion in 'ASP.NET / ASP.NET Core' started by sinclair, Jan 31, 2013.

  1. Does anyone have any experience with determining browser capabilities in ASP.NET 4.0, in particular, for mobile support?

    I am using the MVC4 mobile feature, and this seems to depend on the underlying ASP.NET 4.0 browser detection capabilities (parsing of User Agent string). While things work fine in my development environment, on discountasp.net servers, mobile browsers, with the exception of iPhone, are not detected (desktop version of the page comes up). I've tested with Android, mobile Chrome and mobile Firefox.

    Now I am aware of the browser files under the following directory, which control parsing of the User Agent string and browser capabilities:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Browsers\

    I tried copying these files in my application's App_Browsers folder (except for default.browser file, which otherwise causes ASP.NET to complain), but this still didn't work.

    My questions are (i) are the latest .browser files installed on the servers and (ii) if not, how can customers make best use of this feature without lots of customization (e.g. by having to add code to parse the User Agent string) and essentially replicate unnecessarily the logic already provided by ASP.NET?

    Thank you!
     
  2. For anyone's benefit, I managed to fix this by using 51Degrees.mobi Nuget package. It consists of a regularly updated database of mobile device information (packaged nicely as an assembly) that does away with ASP.NET .browser files altogether, self-initializes and sets up the HttpBrowserCapabilities correctly. It also provides several other pieces of useful information. Check out http://51degrees.codeplex.com/.
     
  3. Nice! Thanks!
     
  4. Thanks Sinclair for sharing the information regarding the software “51degrees.mobi”. Hope this works for me.
     

Share This Page