Uri.EscapeDataString() - Invalid URI: The Uri string is too long

前端 未结 6 1672
难免孤独
难免孤独 2020-12-07 00:14

I\'m using compact framework/C# on windows mobile.

In my application I am uploading data to the server by serializing objects and using a HttpWebRequest/POST request

6条回答
  •  星月不相逢
    2020-12-07 00:54

    Use System.Web.HttpUtility.UrlEncode (based on this answer):

            value = HttpUtility.UrlEncode(value)
                .Replace("!", "%21")
                .Replace("(", "%28")
                .Replace(")", "%29")
                .Replace("*", "%2A")
                .Replace("%7E", "~"); // undo escape
    

提交回复
热议问题