Httputility.urldecode replacement in .Net4?

11,061

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&parameter2=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

HttpUtility Class

Solution 5

You can also use System.Net.WebUtility.UrlDecode

Share:
11,061
Rev
Author by

Rev

Not so sure,but try to be a good developer. ❤ JS and .Net

Updated on June 05, 2022

Comments

  • Rev
    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
    Rev almost 13 years
    oops you right .Net 4 client profile don't support that. but why?
  • alun
    alun almost 13 years
    Why is an excellent question. My guess would be that they just didn't think it through.
  • Didier Caron
    Didier Caron over 9 years
    this 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
    gxclarke almost 7 years
    Escape***String methods are a replacement for UrlEncode. For UrlDecode you need Uri,UnescapeDataString