Simple OO issue

  • Thread starter Thread starter Paul W
  • Start date Start date
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.
 
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
 
Back
Top