Click here to Skip to main content
5,790,650 members and growing! (18,388 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Howto     Intermediate

Get Browser Information Using MobileCapabilities

By Umit TIRIC

Get browser information using MobileCapabilities.
C#.NET 1.1, Win2K, WinXP, Win2003, Windows, .NET, ASP.NET, Visual Studio, Dev

Posted: 15 Jul 2003
Updated: 15 Jul 2003
Views: 31,901
Bookmarked: 20 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
6 votes for this Article.
Popularity: 1.73 Rating: 2.22 out of 5
4 votes, 66.7%
1
0 votes, 0.0%
2
2 votes, 33.3%
3
0 votes, 0.0%
4
0 votes, 0.0%
5

Sample Image - browsercap.jpg

Introduction

ASP.NET provides an extensible mechanism for identifying a mobile client device, and for making the information available to the ASP.NET page framework and the ASP.NET mobile Web application. Like the HttpBrowserCapabilities class, the MobileCapabilities class provides information about the browser making the request. This article explains how you can display all capabilities using reflection, and how you can use them to customize your application for specific mobile devices.

Background

The MobileCapabilities class extends the HttpBrowserCapabilities class. The MobileCapabilities class offers a large number of read-only properties that provide type-safe access to the Browser object's capabilities dictionary.

You can use the Browser property of the HttpRequest object to point to an instance of a MobileCapabilities object, which can then be used to read the capabilities of the requesting browser and device.

Using the code

You can access a lot of information about the browser if your browser is correctly identified using <browsercap> section in machine.config.

// Define

System.Web.Mobile.MobileCapabilities currentCapabilities;
// Get MobileCapabilities from current Request.Browser

MobileCapabilities currentCapabilities = (MobileCapabilities)Request.Browser;
// get a property of the  browser 

string preferredRenderingMIME=currentCapabilities.PreferredRenderingMIME;

Sample code uses System.Reflection to display all properties of MobileCapabilities class.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Umit TIRIC



Location: Saudi Arabia Saudi Arabia

Other popular ASP.NET articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 15 Jul 2003
Editor: Smitha Vijayan
Copyright 2003 by Umit TIRIC
Everything else Copyright © CodeProject, 1999-2009
Web11 | Advertise on the Code Project