Click here to Skip to main content
11,431,483 members (67,659 online)
Click here to Skip to main content

Configuring .Net 2.0 to recognise the BlackBerry browser

, 24 Jul 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
Version 2.0 of the .Net framework does not ship with a configuration file for the Blackberry browser, this article will show how to set one up.

Introduction

While writing ASP.NET applications targeting the BlackBerry browser I have made some interesting discoveries. In this article I will show how to configure .NET 2.0 to recognise the BlackBerry browser so that it behaves as you would expect.

Background

I have developed several ASP.NET 1.1 applications targeting the BlackBerry browser version 4.1 on the 7290 device and more recently the 8700g. I have been upgrading those projects to ASP.NET 2.0 and was quite baffled initially, when several features would just not work.

Creating a BlackBerry.browser config file

After a quick look through the \WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers directory I discovered that version 2.0 of the framework does not ship with configuration details for the BlackBerry browser. Some of the older browsers are covered with the goAmerica.browser configuration file but that doesn't cover the newer browsers.

To find out what the framework knows about a browser you can create a page which writes out some details:

protected void Page_Load(object sender, EventArgs e)
{
    Response.Write("<B>User Agent:</B> " + Request.UserAgent + "<BR />");
    Response.Write("<B>IsMobileDevice:</B> " + Request.Browser.IsMobileDevice
    + "<BR />");
    Response.Write("<B>Browser:</B> " + Request.Browser.Browser + "<BR />");
    Response.Write("<B>Version:</B> " + Request.Browser.Version + "<BR />");
    Response.Write("<B>Major:</B> " + Request.Browser.MajorVersion + "<BR />");
    Response.Write("<B>Minor:</B> " + Request.Browser.MinorVersion + "<BR />");
}

Browsing to this page on a Blackberry the UserAgent will return something like this:
   BlackBerry8700/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/-1
This is useful information but Browser name and version information are not returned.

Creating a Blackberry.browser config file is pretty straight forward. Having a read through the other *.browser files will give you an idea of what properties can be set. Here is the configuration which I have created:

<browsers>

  <browser id="BlackBerry" parentID="Default">
    <identification>
      <userAgent match="BlackBerry(?'model'\d+)/(?'version'((?'major'\d+).
(?'minor'\d+).(?'other'\d+)))" />
    </identification>

    <capabilities>
      <capability name="browser"             value="BlackBerry" />
      <capability name="isMobileDevice"      value="true" />
      <capability name="javascript"          value="true" />
      <capability name="ecmascriptversion"   value="1.3" />          
      <capability name="version"             value="${version}" />
      <capability name="majorVersion"        value="${major}" />
      <capability name="minorVersion"        value="${minor}" />
      <capability name="supportsCss"         value="true" />
      <capability name="frames"              value="false" />
      <capability name="cookies"             value="true" />
    </capabilities>
  </browser>
  
</browsers>

In the browser tag we just set the id and parentID attributes. In the identification tag we create a regular expression to capture a match on the userAgent we looked at earlier. Under capabilities we set the various properties for the browser.

One of the most important capabilities here is the ecmascriptversion. It lets the framework know that its ok to write out the __doPostBack javascript method and the __EVENTTARGET & __EVENTARGUMENT hidden fields. These are used by events such as the SelectedIndexChanged on a DropDownList control.

There are many other properties which can be set but I have found these sufficient for my needs. Enter these details in a text file and save as BlackBerry.browser in the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers directory.

ASP.NET Browser Registration Tool

Creating the file is only half the job. We now need to let the framework know about it. There is a command line tool called aspnet_regbrowsers.exe which creates an assembly based on the information in the *.browser files and installs the assembly in the global assemly cache.

From a command prompt enter the path to aspnet_regbrowsers.exe and use the -i switch to register the browser configurations. For my installation the path is as follows:
   C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regbrowsers.exe -i
Just check that this is the correct location for your installation.

More information on aspnet_regbrowsers.exe can be found here.

Conclusion

The ecmascriptversion can be an important property for the framework to know about a browser. The applications I have upgraded from ASP.NET 1.1 to 2.0 now behave as they should on the BlackBerry browser.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Declan Bright
Architect
Ireland Ireland
I have been designing and developing business solutions for the aviation and telecommunications industries since 1999. My experience covers a wide range of technologies and I have delivered a variety of web and mobile based solutions.

Comments and Discussions

 
GeneralMy vote of 5 Pin
hezhicheng8-Mar-11 9:19
memberhezhicheng8-Mar-11 9:19 
Generalecmascriptversion shows 1.4 but __EventArgument and __EventTarget still don't render Pin
dubloons13-Dec-10 8:31
memberdubloons13-Dec-10 8:31 
GeneralSupport for different Blackberry models Pin
muppet00712-Mar-10 0:51
membermuppet00712-Mar-10 0:51 
GeneralMobile Device Browser File from Codeplex - over 400 devices (including Blackberries) Pin
neilio2-Aug-09 16:52
memberneilio2-Aug-09 16:52 
GeneralIf this isn't working for you - make sure to check the line breaks in your BlackBerry.browser file. Pin
Jesse Fatherree6-Jul-09 11:57
memberJesse Fatherree6-Jul-09 11:57 
General3.5 Support [modified] Pin
Mobby Imam24-Feb-09 10:21
memberMobby Imam24-Feb-09 10:21 
GeneralRe: 3.5 Support Pin
muppet00712-Mar-10 0:47
membermuppet00712-Mar-10 0:47 
This is exactly the same as Declan's .browser file, except RIM added the useless generic xmlns.
GeneralQuestion that might be specific to my BlackBerry Pin
zuurg18-Dec-08 12:45
memberzuurg18-Dec-08 12:45 
GeneralYou can add the BlackBerry.browser file to your project Pin
Rohinton Collins29-Apr-08 14:32
memberRohinton Collins29-Apr-08 14:32 
GeneralRe: You can add the BlackBerry.browser file to your project Pin
Declan Bright30-Apr-08 10:40
memberDeclan Bright30-Apr-08 10:40 
GeneralThank you! Pin
NetNat9-Mar-08 4:15
memberNetNat9-Mar-08 4:15 
GeneralRe: Thank you! Pin
Declan Bright16-Mar-08 8:39
memberDeclan Bright16-Mar-08 8:39 
Questionpostback still failing, any ideas? Pin
dB.29-Oct-07 18:39
memberdB.29-Oct-07 18:39 
AnswerRe: postback still failing, any ideas? Pin
Declan Bright30-Oct-07 0:24
memberDeclan Bright30-Oct-07 0:24 
GeneralRe: postback still failing, any ideas? Pin
dB.30-Oct-07 13:15
memberdB.30-Oct-07 13:15 
Questioni want send message to blackberry from windows desktop application Pin
sriram30308-Aug-07 20:14
membersriram30308-Aug-07 20:14 
AnswerRe: i want send message to blackberry from windows desktop application Pin
Declan Bright8-Aug-07 22:24
memberDeclan Bright8-Aug-07 22:24 
GeneralA slight change needed Pin
zewar962-Aug-07 8:51
memberzewar962-Aug-07 8:51 
GeneralRe: A slight change needed Pin
Declan Bright2-Aug-07 22:51
memberDeclan Bright2-Aug-07 22:51 
GeneralRe: A slight change needed Pin
BrendanM72114-Aug-07 7:01
memberBrendanM72114-Aug-07 7:01 
GeneralRe: A slight change needed Pin
harsha.809-Sep-09 4:01
memberharsha.809-Sep-09 4:01 
GeneralStill Not Working Pin
gialo24-Jul-07 15:23
membergialo24-Jul-07 15:23 
GeneralRe: Still Not Working Pin
Declan Bright24-Jul-07 22:22
memberDeclan Bright24-Jul-07 22:22 
GeneralBlackberry ASP SQL Data Problem Pin
nwack-nwack21-May-07 12:02
membernwack-nwack21-May-07 12:02 
AnswerRe: Blackberry ASP SQL Data Problem Pin
Declan Bright21-May-07 22:33
memberDeclan Bright21-May-07 22:33 
GeneralGreat article Pin
spk1232-Nov-06 7:19
memberspk1232-Nov-06 7:19 
GeneralRe: Great article Pin
Declan Bright2-Nov-06 9:20
memberDeclan Bright2-Nov-06 9:20 
QuestionAdditional Capabilities Pin
esolu18-Sep-06 10:18
memberesolu18-Sep-06 10:18 
AnswerRe: Additional Capabilities [modified] Pin
deccy20-Sep-06 9:30
memberdeccy20-Sep-06 9:30 
GeneralRe: Additional Capabilities Pin
esolu26-Sep-06 4:25
memberesolu26-Sep-06 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.150428.2 | Last Updated 24 Jul 2006
Article Copyright 2006 by Declan Bright
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid