微信设置URL之WebApi方式

微信公众号开发者设置里的URL,现在采用WebAPI的方式,结果一直报“未能正确设置Token”的错误,采用Handler和MVC的方式倒是可以。

解决步骤一,添加服务器IP到白名单。

解决步骤二,确保了代码和方式没有问题。考虑到可能WebAPI返回的 String 值是有问题的,经检查发现Response 里Header不一致,尝试返回Response的类型

HttpResponseMessage。

public HttpResponseMessage CheckVXToken(string signature, string timestamp, string nonce, string echostr)
{
//to-do check return new HttpResponseMessage { Content = new StringContent(echostr, Encoding.GetEncoding("UTF-8"), "application/x-www-form-urlencoded") }; };

原文地址:https://www.cnblogs.com/windy2008/p/7815660.html