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?
UrlDecode(String) Converts a string that has been encoded for transmission in a URL into a decoded string.
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.
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.
//.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With