views:

1996

answers:

3

It'd be really nice to target my Windows Forms app to the .NET 3.5 SP1 client framework. But, right now I'm using the HttpUtility.HtmlDecode and HttpUtility.UrlDecode functions, and the MSDN documentation doesn't point to any alternatives inside of, say, System.Net or something.

So, short from reflectoring the source code and copying it into my assembly---which I don't think would be worth it---are there alternatives inside of the .NET 3.5 SP1 client framework that you know of, to replace this functionality? It seems a bit strange that they'd restrict these useful functions to server-only code.

+1  A: 

The .NET 3.5 SP1 Client Profile Setup Package is the "cut down" version of .NET that only includes what Microsoft perceive to be the "useful" bits of .NET for client applications. So, useful things like the HttpUtility classes are missing.

For more on that see ScottGu's blog, search for "Client Profile Setup Package".

To get around this you could always extract System.Web.dll from the GAC (it'll be in c:\windows\Microsoft.NET\Framework\ ... ) and deploy it with your application. You will, however, need to track updates and service packs as you deploy.

Better might be to take the hit of the full .NET Framework deployment.

Jeremy McGee
A: 

Two main ways :

  1. Deploy using the full .NET Framework
  2. Write your own / 3rd party lib for these functionalities
Andrei Rinea
+3  A: 

I’d strongly not recommend rolling your own encoding. I’d use the Microsoft Anti-Cross Site Scripting Library which is very small (v1.5 is ~30kb) if HttpUtility.HtmlEncode isn’t available.

As for decoding, maybe you could use the decoding routine from Mono?

Ant