Downloads
The sample application includes a binary as well. All you need to do is create a virtual directory in IIS and reconfigure log4net section in web.config file.
How does it work?
ASP.NET usage
Basically, this is a drop-in replacement. If you take a look in global.asax file, you will see that the code there creates a WurflCapabilties object. This object then replaces the Request.Browser object with WurflCapabilities object. There are several ways to query the WURFL database, which can be seen in the provided sample application (lookt at Sample2.aspx.ca file).
If your application uses custom HttpApplication (from which global.asax derives), you can implement that functionality in your application. You could implement that also in an HttpModule.
Important thing to note is that MIT controls will read the WURFL properties, so you instantly get support for new devices (you know that the last Microsoft device update was issued in 2003).
In addition to that, you can get detailed WURFL information about device by using the WURFL API. For instance:
WurflCapabilites mobileCaps = Request.Browser as WurflCapabilities;
mobileCaps.DeviceIndex
will return a WurflDeviceIndex object, where you can see all the WURFL information about this device. To just name a few:
- device fallback
- devices that derive from this device
- all WURFL capabilities
Please note, that information, published on my personal site is no longer accurate. There are problems with replacing the resulting object with WurflCapabilities object. Use the approach outlined in the example specified above or a similar technique.
Also note, that you don’t have to replace the Browser object in order to get those capabilities. You can use WurflDeviceIndex direclty in your code (in your codebehind files, for instance). In this case, the MIT controls will render what browserCaps.config file specifies.
Other uses
You can use the WURFL API from a console application as well. You can load the WURFL manifest (which references the wurfl.xml file and optional patches). For instance:
WurflDownloader downloader = new WurflDownloader();
WurflIndex idx =
downloader.LoadWurfl(”wurfl_manifest.xml”);
WurflLooseMatch looseMatch =
idx.GetDeviceByUaLoose(”Nokia3510i”);
Console.WriteLine(”Match quality: {0}”,
looseMatch.Quality.ToString());
Console.WriteLine(”Device/Manufacturer: {0}/{1}”,
looseMatch.Index[”model_name”].Value,
looseMatch.Index[”brand_name”].Value);
Feedback
Feel free to send comments, suggestions to wmlprogramming group.
This entry was posted
on Tuesday, October 2nd, 2007 at 12:37 pm and is filed under Uncategorized.