One Brain Man

Wednesday, December 21, 2005

 

Watch Out for Request.Browser.MajorVersion in ASP.NET 2.0

I awoke to 1500 exceptions published to me this morning from our public site running ASP.NET 2.0. Not good times. "Luckily" they were all the same: Value cannot be null. It seems one of the components that we are using is calling Request.Browser.MajorVersion and blowing up on goofy user-agents. In this case the user-agent of doom is "YahooSeeker/1.2 (compatible; Mozilla 4.0; MSIE 5.5; yahooseeker at yahoo-inc dot com ; http://help.yahoo.com/help/us/shop/merchant/)". For whatever reason ASP.NET 2.0 cannot parse the MajorVersion out of that and tries to call int.Parse on a null value, causing an error.
Luckily we own the source code to this particular component, so I just wrapped the calls to MajorVersion in a try block so that the entire site doesn't blow up on bogus error codes, so hopefully if you run into that particular error you'll be able to track it down. I haven't tried any of the other properties of the Browser class, but if you are relying on them for anything you might want to first test them out with a rediculous user agent and see what blows up.

Comments: Post a Comment



<< Home

Archives

May 2004   April 2005   May 2005   June 2005   July 2005   August 2005   September 2005   October 2005   December 2005   February 2006   July 2006  

This page is powered by Blogger. Isn't yours?

My Photo
Name: