【发布时间】:2014-04-28 21:41:40
【问题描述】:
我正在开发 Windows Phone 应用程序。因为我需要以 UTF8 编码格式向服务器发送一个 json 字符串。我按照下面提到的方法。
private void RequestStreamCallBack(IAsyncResult ar)
{
try
{
HttpWebRequest request = (HttpWebRequest)ar.AsyncState;
Stream postStream = request.EndGetRequestStream(ar);
string postData = "OPERATION_NAME=" + operationName + "&INPUT_DATA=" + inputData ;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
postStream.Write(byteArray, 0, postData.Length);
postStream.Close();
request.BeginGetResponse(new AsyncCallback(ResponseCallback), request);
}
catch (Exception ex)
{
}
}
inputData 包含 JSON 字符串。到目前为止,它工作得很好。但是现在json字符串有“”字符或“+”字符。当这些字符出现时,服务器不会给出预期的响应。我不知道我错过了什么。
请帮忙。 谢谢。
【问题讨论】:
标签: c# json post windows-phone-8 utf-8