webapi框架微信被动回复消息接收不到

a83068836 2020-07-27 12:43:00
[HttpGet]
[Route("GetByModel")] //路由路径
public HttpResponseMessage GetByModel(string signature, string timestamp, string nonce, string echostr)
{

try
{
string EchoStr = valid(token, signature, timestamp, nonce, echostr);

if (!string.IsNullOrEmpty(EchoStr))
{
return ToHttpMsgForWeChat(echostr);
}
else
{
return ToHttpMsgForWeChat("验证失败!");
}
}
catch (Exception ex)
{
return ToHttpMsgForWeChat(ex.ToString());
}
}
[HttpPost]
//[Route("GetByModel")] //路由路径
/// <summary>
/// 接收用户发送的消息
/// </summary>
public void GetByModel()
{
try
{
HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"];//获取传统context
HttpRequestBase request = context.Request;//定义传统request对象
HttpResponseBase response = context.Response;
string echostr = request.Params["echostr"];
string signature = request.Params["signature"];
string timestamp = request.Params["timestamp"];
string nonce = request.Params["nonce"];
//LogHelper.WriteLog("测试测试");
if (!CheckSignature(token, signature, timestamp, nonce))
{
//WeLogger.Debug("验证消息真实性---失败!");
response.Write(string.Empty);
response.End();
return;
}
string data = ReadStream2String(request.InputStream);
string responseData = ParseMessage(data);
response.Write(responseData);
response.End();

}
catch (Exception ex)
{
//LogHelper.WriteLog(ex.ToString());
}
}



上面一块是验证微信没问题,下面一块收不到信息,有没有大佬帮忙,很急,高分求帮忙
...全文
43 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
a83068836 2020-07-27
  • 打赏
  • 举报
回复
下面一块调试都跳不进去,

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧