解決.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)文章
C#數(shù)據(jù)導(dǎo)入/導(dǎo)出Excel文件及winForm導(dǎo)出Execl總結(jié)
在asp.net中導(dǎo)出Execl有兩種方法.一種是將導(dǎo)出的文件存放在服務(wù)器某個(gè)文件夾下面.一種是將文件直接將文件輸出流寫給瀏覽器2013-01-01
ASP.NET中根據(jù)XML動(dòng)態(tài)創(chuàng)建使用WEB組件
ASP.NET中根據(jù)XML動(dòng)態(tài)創(chuàng)建使用WEB組件...2006-09-09
基于asp.net實(shí)現(xiàn)圖片在線上傳并在線裁剪功能
本文主要介紹了基于asp.net實(shí)現(xiàn)圖片在線上傳并在線裁剪功能的具體事例代碼,具有一定的參考價(jià)值。需要的朋友可以參考下2016-12-12
asp.net C#實(shí)現(xiàn)下載文件的六種方法實(shí)例
asp.net C#實(shí)現(xiàn)下載文件的六種方法實(shí)例,需要的朋友可以參考一下2013-04-04
.NET?6開發(fā)TodoList應(yīng)用之使用MediatR實(shí)現(xiàn)POST請求
對于稍微正式的項(xiàng)目,.NET工程上習(xí)慣的實(shí)現(xiàn)是通過使用比較成熟的類庫框架,有效地對業(yè)務(wù)邏輯進(jìn)行分類管理、消除冗余代碼,以達(dá)到業(yè)務(wù)邏輯職責(zé)清晰簡潔的目的。在這個(gè)階段我們經(jīng)常使用的兩個(gè)類庫分別是AutoMapper和MediatR。本文將為大家介紹MediatR如何實(shí)現(xiàn)POST請求2021-12-12
asp.net String.IsNullOrEmpty 方法
2009-04-04

