accessing Request.Browser throws an exception

Discussion in 'ASP .Net' started by germ, Jul 5, 2007.

  1. germ

    germ Guest

    we are running into a situation where accessing Request.Browser.MajorVersion
    causes a System.ArgumentNullException.

    when this happens the HTTP_USER_AGENT value is "Mozilla/4.x (Win95)"

    I am assuming that this problem is that this agent string is not being
    recognized.
    I would have thought that this would result in some type of unknown browser
    browser object being created rather that had some type of value for all
    properties but surely nothing null.

    Is there a fix for this or do we have to wrap all references to
    Request.Browser in a try/catch ?

    Gerry
     
    germ, Jul 5, 2007
    #1
    1. Advertising

  2. germ wrote:
    > we are running into a situation where accessing Request.Browser.MajorVersion
    > causes a System.ArgumentNullException.
    >
    > when this happens the HTTP_USER_AGENT value is "Mozilla/4.x (Win95)"
    >
    > I am assuming that this problem is that this agent string is not being
    > recognized.
    > I would have thought that this would result in some type of unknown browser
    > browser object being created rather that had some type of value for all
    > properties but surely nothing null.


    There is nothing in the documentation about the Browser property that it
    may be null, but obviously it can.

    > Is there a fix for this or do we have to wrap all references to
    > Request.Browser in a try/catch ?


    Just check if the Browser property is null before using it.

    --
    Göran Andersson
    _____
    http://www.guffa.com
     
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Jul 6, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Himmat Dhange
    Replies:
    0
    Views:
    456
    Himmat Dhange
    Aug 26, 2003
  2. Brian Birtle
    Replies:
    2
    Views:
    2,182
    John Saunders
    Oct 16, 2003
  3. Chris Miller
    Replies:
    4
    Views:
    13,565
    Chris Smith
    Nov 22, 2003
  4. Replies:
    2
    Views:
    357
  5. Replies:
    4
    Views:
    461
    Robert Smith
    Jun 5, 2014
Loading...

Share This Page