就是吧微信发过来的echoStr原样返回就可以了。
点击提交后微信会向我们填写的服务器发送几个参数,然后需要原样返回出来,所以在提交url的时候,先在服务器创建接口测试返回echostr参数内容
不多说直接上代码: 在一般处理程序创建如下代码就ok了。
public void ProcessRequest(HttpContext context) { string postString = string.Empty; string token = "zhulang";//你申请的时候填写的Token string echoString = HttpContext.Current.Request.QueryString["echoStr"]; string signature = HttpContext.Current.Request.QueryString["signature"]; string timestamp = HttpContext.Current.Request.QueryString["timestamp"]; string nonce = HttpContext.Current.Request.QueryString["nonce"]; //返回给微信服务器 if (!String.IsNullOrEmpty(echoString)) { HttpContext.Current.Response.Write(echoString); HttpContext.Current.Response.End(); } }
微信URL填写。 提交认证成功。