I am trying to write a windows client application that calls a web site for data. To keep the install to a minimum I am trying only use dlls in the .NET Framework Client Profile. Trouble is that I need to UrlEncode some parameters, is there an easy way to do this without importing System.Web.dll which is not part of the Client Pofile?
C# – How to UrlEncode without using System.Web
.net.net-client-profilec++urlencode
Related Question
- C# – How to enumerate an enum
- C# – Should ‘using’ directives be inside or outside the namespace
- C# – How to create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office
- C# – How to convert a byte array to a hexadecimal string, and vice versa
- C# – How to get a consistent byte representation of strings in C# without manually specifying an encoding
- C# – a NullReferenceException, and how to fix it
- Python – How to urlencode a querystring in Python
Best Solution
System.Uri.EscapeUriString()
can be problematic with certain characters, for me it was a number / pound '#' sign in the string.If that is an issue for you, try:
Here is a SO question answer that explains the difference:
What's the difference between EscapeUriString and EscapeDataString?
and recommends to use
Uri.EscapeDataString()
in any aspect.