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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
The answers here are very good, but still insufficient for me.
I wrote a small loop that compares
Uri.EscapeUriString
withUri.EscapeDataString
for all characters from 0 to 255.NOTE: Both functions have the built-in intelligence that characters above 0x80 are first UTF-8 encoded and then percent encoded.
Here is the result:
EscapeUriString
is to be used to encode URLs, whileEscapeDataString
is to be used to encode for example the content of a Cookie, because Cookie data must not contain the reserved characters'='
and';'
.To UrlEncode without using System.Web:
more details: https://www.samnoble.co.uk/2014/05/21/beware-webutility-urlencode-vs-httputility-urlencode/