How to use HttpServerUtility?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
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
 

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

Back
Top