Friday, February 22, 2008
There are times where you require web methods like Server.HtmlDecode and Server.HtmlEncode for use within your business layer.
To get access to these methods one needs to firstly add the System.Web reference to your application project there by exposing these methods to your project.
Next, make reference within your class to the System.Web class.
Now you can access all of System.Web's methods.

For example:
 HttpContext.Current.Server.HtmlDecode("");
 HttpContext.Current.Server.HtmlEncode("");

Friday, August 28, 2009 2:13:52 PM (South Africa Standard Time, UTC+02:00)
For encoding / decoding methods, you can also use the static methods in the HttpUtility object. The advantage of this method is that the calls won't fail with a null reference exception when HttpContext.Current is null. I've needed this from time to time, eg when running code in a worker thread, or in the Start event of your Application object.
Alex
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):