Solved

Retrieving the Request.UserAgent in a class

Posted on 2014-02-11
3
370 Views
Last Modified: 2014-02-12
Is it possible to retrieve the useragent in a class?

I have tried:
Dim userAgent As String = Request.UserAgent

Open in new window


And System.Web.HttpRequest etc. but it errors saying:
reference to a non-shared member requires an object reference

Can I not put this in an App_Code class?

thanks!
0
Comment
Question by:Starr Duskk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:Jitendra Patil
ID: 39852700
hi,
The error you are getting becuase you are trying to access a non shared method OR a method of a class without its instance.

You either have to make the method Shared or use an instance of the class by creating an instance of an object.

hope this helps.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39853671
Try

Dim userAgent As String = HTTPContext.Current.Request.UserAgent
0
 
LVL 2

Author Closing Comment

by:Starr Duskk
ID: 39854031
thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question