How do I decode HTML that was encoded in JS using encodeURIComponent()?

I tried :

string decodedHtml = HttpUtility.HtmlDecode(html);

Where html is the encoded html. It seems that this does not alter the string at all. The html is still encoded.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

string s = System.Uri.UnescapeDataString(html);

Method 2

Think you can use this code.

HttpContext.Current.Server.UrlDecode(html)

Method 3

`

<p>Click the button to encode a URI.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
  var uri = "https://informerspro.com";
  var res = encodeURIComponent(uri);
  document.getElementById("demo").innerHTML = res;
}
</script>

`


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x