Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I decode a URL parameter using C#?

People also ask

What is Httputility Urldecode?

Converts a string that has been encoded for transmission in a URL into a decoded string.

How do I decode a Google URL?

You can decode them by either using a keyboard shortcut (CTRL + SHIFT + ALT + D), or by clicking on the decode URLS context menu link, or by clicking on decode URLS from the plugin icon at the top.

Does browser automatically decode URL?

kinda de-facto standard yes. but only in modern browsers. its done for user convienience, so you can put utf8 charactesr in an url and its still pretty to the human eye. however please be aware that the text is actually still encoded and will be transmittet/requested encoded, it is only displayed decoded.


string decodedUrl = Uri.UnescapeDataString(url)

or

string decodedUrl = HttpUtility.UrlDecode(url)

Url is not fully decoded with one call. To fully decode you can call one of this methods in a loop:

private static string DecodeUrlString(string url) {
    string newUrl;
    while ((newUrl = Uri.UnescapeDataString(url)) != url)
        url = newUrl;
    return newUrl;
}

Server.UrlDecode(xxxxxxxx)

Have you tried HttpServerUtility.UrlDecode or HttpUtility.UrlDecode?


Try:

var myUrl = "my.aspx?val=%2Fxyz2F";
var decodeUrl = System.Uri.UnescapeDataString(myUrl);

Try this:

string decodedUrl = HttpUtility.UrlDecode("my.aspx?val=%2Fxyz2F");