[WebMethod]
public string Receive()
{
try
{
Stream stream = HttpContext.Current.Request.InputStream;
byte[] reader = new byte[stream.Length];
stream.Read(reader, 0, (int)stream.Length);
string receiveContent = Encoding.UTF8.GetString(reader);
//receiveContent = HttpUtility.UrlDecode(reader,Encoding.GetEncoding("utf-8"));
if ((new OperationFromYZ()).Operate(receiveContent))
{
(new WriteLog()).DoWriteLog("02被动接收有赞方数据并已成功执行" + "\t\t" + DateTime.Now.ToString() + "\t\t" + receiveContent);
Config.Test = receiveContent;
return "{\"code\":0,\"msg\":\"success\"}";
}
else
{
(new WriteLog()).DoWriteLog("!被动接收有赞方数据但执行错误" + "\t\t" + DateTime.Now.ToString() + "\t\t" + receiveContent);
return "error from zs 01";
}
}
catch
{
(new WriteLog()).DoWriteLog("!被动接收有赞方数据但接收错误" + "\t\t" + DateTime.Now.ToString());
return "error from zs 02";
}
}
这是我写的接收有赞推送的C#代码,结果接收到的消息写入txt文档就是一串空格,写入web.config文件就是一串����������字符,请C#的程序师帮忙看一下是哪里出的问题,谢谢!
补充说明:这段代码可以接收到我自己编写的发送,但是没有试过用json格式发送。
|
|
用手机打开
收藏
赞 0
···
回复
|
|
|
|