Simple OO issue

P

Paul W

I want to refer to server.machinename in a module (not code-behind a page).

If I try:

dim uu as string
uu = System.Web.HttpServerUtility.MachineName

I get a compile error "Reference to a non-shared member requires an object
reference". Huh?

(If you can also point me to where I can read-up on what I'm missing, I'd
appreciate it).

Paul.
 
C

Chris R. Timmons

I want to refer to server.machinename in a module (not
code-behind a page).

If I try:

dim uu as string
uu = System.Web.HttpServerUtility.MachineName

I get a compile error "Reference to a non-shared member requires
an object reference". Huh?

(If you can also point me to where I can read-up on what I'm
missing, I'd appreciate it).

Paul,

Try

dim uu as string
uu = HttpContext.Current.Server.MachineName

Asp.Net automatically creates instances of HttpContext, HttpRequest,
HttpResponse and HttpServerUtility. All of these instances are
available to the current context, as shown above (see the help entry
for System.Web.HttpContext). Also, the HttpRequest and HttpResponse
instances are also available thru the current page (see the help
entry for System.Web.UI.Page).

Read this for more info:

http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconcreatingaspwebapplications.asp

or

http://tinyurl.com/6kgsw
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top