How to use HttpServerUtility?

Discussion in 'ASP .Net' started by =?Utf-8?B?UGF0cmljayBG?=, Feb 14, 2006.

  1. I have a dll file that i am trying to use the Server.Encode function.
    so i have added a reference to System.Web;

    but when im trying to delcare:
    HttpServerUtility mServer = new HttpServerUtility();
    return mServer.HtmlEncode(strValue);

    i get the following error:
    Error The type 'System.Web.HttpServerUtility' has no constructors defined

    Is there a list to find what constructors to use? how do you know how to
    declare if you dont have any references or examples of this?
     
    =?Utf-8?B?UGF0cmljayBG?=, Feb 14, 2006
    #1
    1. Advertising

  2. The HttpServerUtility.HtmlEncode method is static. It doesn't require an
    instance. Just call HttpUtility.HtmlEncode(whatever).

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    We got a sick zebra a hat,
    you ultimate tuna.


    "Patrick F" <> wrote in message
    news:...
    >I have a dll file that i am trying to use the Server.Encode function.
    > so i have added a reference to System.Web;
    >
    > but when im trying to delcare:
    > HttpServerUtility mServer = new HttpServerUtility();
    > return mServer.HtmlEncode(strValue);
    >
    > i get the following error:
    > Error The type 'System.Web.HttpServerUtility' has no constructors defined
    >
    > Is there a list to find what constructors to use? how do you know how to
    > declare if you dont have any references or examples of this?
     
    Kevin Spencer, Feb 14, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?UGF0cmljayBG?=

    Hans Kesting Guest

    Re: =?UTF-8?B?SG93IHRvIHVzZSBIdHRwU2VydmVyVXRpbGl0eT8=?=

    > I have a dll file that i am trying to use the Server.Encode function.
    > so i have added a reference to System.Web;
    >
    > but when im trying to delcare:
    > HttpServerUtility mServer = new HttpServerUtility();
    > return mServer.HtmlEncode(strValue);
    >
    > i get the following error:
    > Error The type 'System.Web.HttpServerUtility' has no constructors defined
    >
    > Is there a list to find what constructors to use? how do you know how to
    > declare if you dont have any references or examples of this?


    You can access it via System.Web.HttpContext.Current.Server, BUT: this
    will only work if there really *is* an HttpContext (else Current is
    null).

    Hans Kesting
     
    Hans Kesting, Feb 15, 2006
    #3
  4. =?Utf-8?B?UGF0cmljayBG?=

    isaiyavan

    Joined:
    Jul 4, 2008
    Messages:
    1
    Location:
    Computers
    do like the following:

    HttpServerUtility Server = HttpContext.Current.Server;

    then u can use the Server.HtmlEncode ..... etc methods and functions...
     
    isaiyavan, Jul 4, 2008
    #4
    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. Supriya
    Replies:
    0
    Views:
    479
    Supriya
    Jul 1, 2003
  2. Brendan Erwin

    HttpServerUtility.GetLastError Timing issue?

    Brendan Erwin, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    547
    bruce barker
    Dec 2, 2003
  3. =?Utf-8?B?Sm9l?=
    Replies:
    19
    Views:
    9,188
    Daryn
    May 22, 2008
  4. =?Utf-8?B?QXJuZQ==?=

    HttpServerUtility instance method

    =?Utf-8?B?QXJuZQ==?=, Aug 17, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    417
    =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=
    Aug 17, 2007
  5. Arne

    HttpServerUtility

    Arne, Aug 4, 2009, in forum: ASP .Net
    Replies:
    5
    Views:
    807
    Gregory A. Beamer
    Aug 5, 2009
Loading...

Share This Page