Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to UrlDecode without having System.Web dll in c#

I'm about to create a self-hosted Web API application, and somewhere I need to URL Decode the input. But I truly don't want to add a reference to System.Web.dll, because AMAIK, it's a heavy DLL and one of the main reasons of getting far from ASP.NET and IIS.

If I'm right, and I don't add a reference to System.Web, then how can I URL Decode effectively without bugs?

like image 874
h.Ebrahimi Avatar asked Jan 23 '16 13:01

h.Ebrahimi


People also ask

What is Urldecode C#?

UrlDecode(String) Converts a string that has been encoded for transmission in a URL into a decoded string.

How do you know if a string is already URL encoded or not?

So you can test if the string contains a colon, if not, urldecode it, and if that string contains a colon, the original string was url encoded, if not, check if the strings are different and if so, urldecode again and if not, it is not a valid URI.

How can I get Urldecode in PHP?

PHP | urldecode() Function The urldecode() function is an inbuilt function in PHP which is used to decode url which is encoded by encoded() function. Parameters: This function accepts single parameter $input which holds the url to be decoded. Return Value: This function returns the decoded string on success.


1 Answers

//.Net 4.0+

you can use WebUtility.UrlDecode(). It is not part of system.web.

And you can see this blog: Html and Uri String Encoding without System.Web

like image 69
Anik Saha Avatar answered Oct 01 '22 12:10

Anik Saha