【发布时间】:2010-10-20 16:46:58
【问题描述】:
过去,当我将 C# 应用程序中的内容上传到网站时,我使用过这样的 POST 请求:
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create("http://" + this.server + "/log.php");
wr.Method = "POST";
wr.ContentType = "application/x-www-form-urlencoded";
string paramString = "v=" + this.version + "&m=" + this.message;
wr.ContentLength = paramString.Length;
StreamWriter stOut = new StreamWriter(wr.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(paramString);
stOut.Close();
我的问题是,现在我处于this.message 很可能包含换行符、制表符和特殊字符(包括“&”和“=”)的情况。我是否需要转义此内容。如果有,怎么做?
【问题讨论】:
标签: c# httpwebrequest escaping