解決.NET?Core企業(yè)微信openapi回調(diào)地址請求不通過的問題
1.問題截圖
2.測試回調(diào)模式成功
測試回調(diào)模式地址https://open.work.weixin.qq.com/wwopen/devtool/interface/combine,建立連接 => 測試回調(diào)模式
3.解決
測試回調(diào)成功,但是發(fā)現(xiàn)返回結(jié)果帶了引號,可能是導(dǎo)致回調(diào)不成功原因。下面代碼為錯(cuò)誤示范。
[HttpGet, Route("callback/interAspect")] public IActionResult ReveiceMsg(string msg_signature,string timestamp,string nonce,string echostr) { //驗(yàn)證 WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(AppSetting.Configuration["Wx:CallBackToken"] , AppSetting.Configuration["Wx:EncodingAESKey"] , AppSetting.Configuration["Wx:corpid"]); int ret = 0; string sEchoStr = ""; ret = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr, ref sEchoStr); if (ret != 0) { return Json(null); } return Json(sEchoStr); }
返回值調(diào)整為ContentResult 或者string 后測試成功。
[HttpGet, Route("callback/interAspect")] public ContentResult ReveiceMsg(string msg_signature,string timestamp,string nonce,string echostr) { //驗(yàn)證 WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(AppSetting.Configuration["Wx:CallBackToken"] , AppSetting.Configuration["Wx:EncodingAESKey"] , AppSetting.Configuration["Wx:corpid"]); int ret = 0; string sEchoStr = ""; ret = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echostr, ref sEchoStr); if (ret != 0) { return Content(null); } return Content(sEchoStr); }
最后成功保存
服務(wù)端加解密庫: https://developer.work.weixin.qq.com/tool#/tab/invoke/source
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
ASP.NET?MVC+EF實(shí)現(xiàn)異步增刪改查
這篇文章介紹了ASP.NET?MVC+EF實(shí)現(xiàn)異步增刪改查的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03用 Asp.Net 建立一個(gè)在線 RSS 新聞聚合器的方法
用 Asp.Net 建立一個(gè)在線 RSS 新聞聚合器的方法...2007-04-04asp.net中不能在DropDownList中選擇多個(gè)項(xiàng) 原因分析及解決方法
不能在 DropDownList 中選擇多個(gè)項(xiàng),在前一步操作的過程中,已經(jīng)選擇了某個(gè)Item2012-10-10已有打開的與此命令相關(guān)聯(lián)的DataReader,必須首先將它關(guān)閉。對于此異常的理解
今天與大家分享一下 已有打開的與此命令相關(guān)聯(lián)的DataReader,必須首先將它關(guān)閉。這個(gè)異常的個(gè)人理解2012-01-01Asp.Net套用母版頁后元素ID不一致(個(gè)人總結(jié))
這篇文章主要介紹了Asp.Net套用母版頁后元素ID不一致(個(gè)人總結(jié)),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-11-11