HttpServerUtility

A

Arne

How do get an instance of the server so that I can execute
HttpServerUtility.UrlEncode ?
 
G

Gregory A. Beamer

How do get an instance of the server so that I can execute
HttpServerUtility.UrlEncode ?

In ASP.NET, you find most things of this nature on the Context object.

For C#, it is

this.Context

Not tested: In VB it should be

Me.Context

Hope this helps!

Peace and Grace,
 
G

Gregory A. Beamer

That works well in a web page, but not in a library routine.

I made an assumption based on the group, which was probably not the
right thing to do.

If your libraries are not strongly coupled to the application, you can
pass in a context.

If you simply want to URL encode, however, you can use the HttpUtility
class. To do this:

1. Reference System.Web
2. Add a using/Imports statement (to be language agnostic)


Code (C#)
string encodedString = HttpUtility.UrlEncode(itemToEncode);

Code (VB)
Dim encodedString as String = _
HttpUtility.UrlEncode(itemToEncode)


Peace and Grace,
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top