13

I need HttpUtility for encoding strings, but it seems it was supported, but no longer. Actually, the whole System.Web is gone.

Is there an alternative? I need to Javascript Escape some strings.

angel of code
  • 686
  • 8
  • 25

2 Answers2

19

The HttpUtility class lives in the System.Web.Services assembly, just make sure that you are referencing that assembly.

miguel.de.icaza
  • 32,654
  • 6
  • 58
  • 76
  • 2
    Its a bit confusing that I can just see System.Web.Services in the references, but not System.Web. But adding Services gives me Web too. thanks. – angel of code May 09 '11 at 09:24
  • 7
    To clarify - HttpUtility is inside System.Web.dll in the desktop/server framework. However, since MonoTouch doesn't include ASP.NET, HttpUtility was moved to System.Web.Services.dll. – Mikayla Hutchinson May 11 '11 at 01:13
  • 1
    To further clarify, the namespace is still the same although it's in the different `.dll`, i.e. you still need `using System.Web` and _not_ `using System.Web.Services`. – DJH Sep 17 '15 at 21:44
1

I am using Xamarin Studio with Mono 3.0.10 and in there, you need to reference the System.Web dll and include it with

using System.Web;

Then you will have the HTTPUtility and encode/decode functionality available

EeKay
  • 6,494
  • 3
  • 24
  • 24