HttpServerUtility

  • Thread starter Thread starter Arne
  • Start date Start date
A

Arne

How do get an instance of the server so that I can execute
HttpServerUtility.UrlEncode ?
 
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,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
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,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top