为了账号安全,请及时绑定邮箱和手机立即绑定

微信服务器配置修改的时候总是提示token验证失败

第一次验证是通过的,消息推送也非常好,最近换了服务器和域名,想变更过来,但每次修改总是提示token验证失败,查找了很多方法都不行,原码如下,请各位大神赐教,在线等,非常着急
using System;
using System.Collections.Generic;
using System.Web;
using System.IO;
using System.Text;
using System.Net;

namespace fz_police.Web
{
    /// <summary>
    /// Summary description for wx
    /// </summary>
    public class wx : IHttpHandler
    {

        public void ProcessRequest(HttpContext param_context)
        {
            //InterfaceTest();
            string postString = string.Empty;
            if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
            {
                using (Stream stream = HttpContext.Current.Request.InputStream)
                {
                    Byte[] postBytes = new Byte[stream.Length];
                    stream.Read(postBytes, 0, (Int32)stream.Length);
                    postString = Encoding.UTF8.GetString(postBytes);
                    Handle(postString);
                }
            }
        }

        /// <summary>
        /// 处理信息并应答
        /// </summary>
        private void Handle(string postStr)
        {
            MessageHelp help = new MessageHelp();
            string responseContent = help.ReturnMessage(postStr);

            HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
            HttpContext.Current.Response.Write(responseContent);
        }

        //成为开发者url测试,返回echoStr
        public void InterfaceTest()
        {
            string token = "fzgonganweixin";
            if (string.IsNullOrEmpty(token))
            {
                return;
            }

            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();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }


    }
}

正在回答

0 回答

举报

0/150
提交
取消

微信服务器配置修改的时候总是提示token验证失败

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号