Wednesday, August 20, 2008

Reflecting On Browser Properties


We are armpit deep in Mobile Development and facing multiple Level 2 Ignorance traps.
One area concerns browsers. As each Mobile Platform has a unique browser and browser settings.
To help with this, we have a page where we use Reflection to dump out the browser properties.
Note the code has a "evil" empty try catch, our code is similar (read much improved).
But I though it would be handy to provide the essence of the solution.
Type
browserType = Request.Browser.GetType();
foreach (PropertyInfo propertyInfo in
browserType.GetProperties())
{
try
{
Response.Write(propertyInfo.Name +
" : " + propertyInfo.GetValue(Request.Browser, null).ToString()
;
}
catch
{
}
}

No comments: