Simple OO issue

Discussion in 'ASP .Net' started by Paul W, Nov 21, 2004.

  1. Paul W

    Paul W Guest

    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.
    Paul W, Nov 21, 2004
    #1
    1. Advertising

  2. "Paul W" <> wrote in
    news:OiEHYA#:

    > 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

    --
    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
    Chris R. Timmons, Nov 21, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. darrel

    Simple issue tracker? Wiki?

    darrel, Jan 4, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    632
    clintonG
    Jan 5, 2006
  2. Newbie

    Simple, unsolved issue

    Newbie, Apr 12, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    707
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Apr 12, 2006
  3. nAnd0
    Replies:
    39
    Views:
    1,123
    Toby Inkster
    Sep 8, 2005
  4. Jacek Dziedzic
    Replies:
    2
    Views:
    321
    Jakob Bieling
    Oct 17, 2003
  5. Srini
    Replies:
    11
    Views:
    967
    Arne Vajhøj
    Jun 1, 2008
Loading...

Share This Page