Solved

Retrieving the Request.UserAgent in a class

Posted on 2014-02-11
3
365 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:BobCSD
3 Comments
 
LVL 12

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 1

Author Closing Comment

by:BobCSD
ID: 39854031
thanks!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now