Httputility.urldecode replacement in .Net4?
Solution 1
If you really have to run against the client profile (which doesnt include HttpUtility) then you could check this Alternative to HttpUtility for .NET 3.5 SP1 client framework?. (That question is about 3.5 sp1 but nothing has changed in this regard in 4.0)
You really should see if you can't just use the full framework though.
Solution 2
HttpUtility is wild goose chase for c# users since it's not already there (referenced)
2 alternatives :
string a = System.Uri.EscapeUriString("https://some.url.goes.here"); // for path
string b = System.Uri.EscapeDataString("parameter1=1¶meter2=something"); // for params
Solution 3
Try the UrlDecode method on HttpServerUtility:
System.Web.HttpContext.Current.Server.UrlDecode()
Solution 4
As you can see in below link, .NET Framework 4 is supporting the HttpUtility. As @Alun is mentioend above, I think you use .NET 4 Client Profile
Solution 5
You can also use System.Net.WebUtility.UrlDecode
Comments
-
Rev almost 2 years
I got an
old Program(class library)
developed by.Net 2
. Recently I want to use that Program in new project which is use.Net4(For new WPF feature's )
. so there is a big problem:.Net4 don't support System.Web and as result it can't be use Httputility.urldecode!!
So what is
urldecode
jop? and how can I change that to something, which is support by.Net4
? -
Rev almost 13 yearsoops you right .Net 4 client profile don't support that. but why?
-
alun almost 13 yearsWhy is an excellent question. My guess would be that they just didn't think it through.
-
Didier Caron over 9 yearsthis should be the accepted answer, adding System.Web just for the sake of escaping and unescaping an string is just not the way to go.
-
gxclarke almost 7 yearsEscape***String methods are a replacement for UrlEncode. For UrlDecode you need Uri,UnescapeDataString