Solved

Retrieving the Request.UserAgent in a class

Posted on 2014-02-11
3
367 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
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 2

Author Closing Comment

by:Starr Duskk
ID: 39854031
thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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