新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
微信開發(fā)中如何接入asp.net-創(chuàng)新互聯(lián)
這篇文章主要介紹微信開發(fā)中如何接入asp.net,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
首先創(chuàng)建一個Default.aspx。在Page_Load里進(jìn)行檢驗(yàn):(MyLog是日志類,可以忽略) 關(guān)于checkSignature()就和所查到的差不多了。這里貼一下。
MyLog.DebugInfo("request default.aspx"); String echoStr = Request.QueryString["echostr"]; MyLog.DebugInfo("echoStr:"+echoStr); if (this.checkSignature()) { if(!string.IsNullOrEmpty(echoStr)){ MyLog.DebugInfo("echostr:" + echoStr); Response.Write(echoStr); Response.End(); } }
最最主要的是那句Response.End(),不加這一句怎么樣都接不進(jìn)去(希望有大神告知)。 關(guān)于checkSignature()就和所查到的差不多了。這里貼一下
private bool checkSignature() { string signature = Request["signature"]; string timestamp = Request["timestamp"]; string nonce = Request["nonce"]; MyLog.DebugInfo(String.Format("signature:{0},timestamp:{1},nonce:{2}", signature, timestamp, nonce)); string token = TOKEN; string[] tmpArr = new string[] { token, timestamp, nonce }; Array.Sort(tmpArr); string tmpStr = string.Join("", tmpArr); //sha1加密 System.Security.Cryptography.SHA1 sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); byte[] secArr = sha1.ComputeHash(System.Text.Encoding.Default.GetBytes(tmpStr)); tmpStr = BitConverter.ToString(secArr).Replace("-", "").ToLower(); MyLog.DebugInfo(String.Format("after parse:{0}", tmpStr)); if (tmpStr == signature) { MyLog.DebugInfo("true"); return true; } else { return false; }
以上是“微信開發(fā)中如何接入asp.net”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
本文標(biāo)題:微信開發(fā)中如何接入asp.net-創(chuàng)新互聯(lián)
本文路徑:http://fisionsoft.com.cn/article/dsdpci.html