private XDocument Init(XDocument postDataDocument, ReceiveRequestData postModel)
        {
            //进行加密判断并处理

            var       postDataStr = postDataDocument.ToString();
            XDocument decryptDoc  = postDataDocument;

            if (postModel != null && postDataDocument.Root.Element("Encrypt") != null && !string.IsNullOrEmpty(postDataDocument.Root.Element("Encrypt").Value))
            {
                //使用了加密
                string        sToken          = wxconfig.ServerToken;          //消息校验Token
                string        sAppId          = wxconfig.ServerAppID;          //申请到的第三方平台APPID
                string        sEncodingAesKey = wxconfig.ServerEncodingAESKey; //消息加解密Key
                WXBizMsgCrypt wxcpt           = new WXBizMsgCrypt(sToken, sEncodingAesKey, sAppId);
                string        msgXml          = null;
                var           result          = wxcpt.DecryptMsg(postModel.msg_signature, postModel.timestamp, postModel.nonce, postDataStr, ref msgXml);
                //判断result类型
                if (result != 0)
                {
                    Log4NetHelper.logText("Init", "未解密成功");
                    //验证没有通过,取消执行
                    return(null);
                }

                decryptDoc = XDocument.Parse(msgXml);//完成解密
            }
            return(decryptDoc);
        }
 /// <summary>
 /// 接收component_verify_ticket协议
 /// </summary>
 /// <param name="postModel"></param>
 /// <param name="inputStream"></param>
 /// <returns></returns>
 public ResponseAuthEventReceiveMsg Component_verify_ticket(ReceiveRequestData postModel, Stream inputStream)
 {
     if (inputStream != null)
     {
         inputStream.Seek(0, SeekOrigin.Begin);//强制调整指针位置
         using (XmlReader xr = XmlReader.Create(inputStream))
         {
             var postDataDocument = XDocument.Load(xr);
             var result           = Init(postDataDocument, postModel);
             var resultMessage    = new ResponseAuthEventReceiveMsg();
             //xml to model
             EntityHelper.FillEntityWithXml(resultMessage, result);
             return(resultMessage);
         }
     }
     //else
     //{
     //Log4NetHelper.logText("timestamp", "时间戳未获取到");
     return(null);
     //}
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            ReceiveRequestData postModel = new ReceiveRequestData();

            postModel.signature     = Request["signature"];
            postModel.timestamp     = Request["timestamp"];
            postModel.nonce         = Request["nonce"];
            postModel.encrypt_type  = Request["encrypt_type"];
            postModel.msg_signature = Request["msg_signature"];


            //using (var streamReader = new StreamReader(Request.InputStream))
            //{
            //    string stringInput1 = streamReader.ReadToEnd();
            //    Log4NetHelper.logText("stream", stringInput1);
            //}
            ResponseAuthEventReceiveMsg response = Component_verify_ticket(postModel, Request.InputStream);

            if (response != null)
            {
                Log4NetHelper.logText("ComponentVerifyTicket", response.ComponentVerifyTicket);
            }
        }