0
我有一些代碼使用httpWebRequest發佈數據,但是當我在引用中使用unicode文本時,它總是顯示異常:「指定的值具有無效的控制字符。」httpWebRequest引用異常與unicode網址
CookieContainer cookieContainer = new CookieContainer();
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Headers["Accept-Encoding"] = "gzip, deflate";
httpWebRequest.AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate);
httpWebRequest.Timeout = this.Timeout;
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.Method = method;
httpWebRequest.KeepAlive = this.KeepAlive;
httpWebRequest.ContentType = this.ContentType;
httpWebRequest.Accept = this.Accept;
httpWebRequest.UserAgent = this.UserAgent;
httpWebRequest.Referer = this.Referer;
httpWebRequest.ProtocolVersion = HttpVersion.Version11;
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.ServicePoint.Expect100Continue = false;
httpWebRequest.AllowWriteStreamBuffering = false;
httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
httpWebRequest.Proxy = WebRequest.DefaultWebProxy;
的網址是:somewhere.com/index?1yyezksvrgzkelork□=rgu{z5iihy5zvreiihy&1iutlomLork=gjsot5otjk~
的Referer:somewhere.com/index?1yyezksvrgzkelork□=rgu{z5iihy5zvreiihy&1iutlomLork=gjsot5otjk~
如果只使用URL它的正常運行。