我似乎無法找到一種方法來為通用 asp.net webhooks 設定這樣的 URI,其路由以 /portalapi/v1/* 開頭。例如這樣的事情:
config.Routes.MapHttpRoute(
name: "PortalApi",
routeTemplate: "portalapi/v1/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
webhook 接收器似乎只以 api/* 的形式回應來自 URI 的帖子:
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
我錯過了什么嗎?或者這是一個錯誤?有沒有人能夠改變路線的起點并被網路鉤子電話接受?
我通讀了這個微軟檔案,但沒有找到任何答案:https : //docs.microsoft.com/en-us/aspnet/webhooks/receiving/receivers
我在 github 上有一張與 AspNetWebHooks 團隊的公開票。 https://github.com/aspnet/AspNetWebHooks/issues/62
uj5u.com熱心網友回復:
您不能,因為它不受支持,并且該專案處于維護模式,因此永遠不會得到支持。
查看源代碼:
// Use a constant template since all WebHook constraints use the resulting route values and we have no
// requirements for user-specified route templates.
private static string ChooseTemplate()
{
var template = "/api/webhooks/incoming/"
$"{{{WebHookConstants.ReceiverKeyName}}}/"
$"{{{WebHookConstants.IdKeyName}?}}";
return template;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/337263.html
標籤:C# asp.net asp.net-mvc asp.net-webhooks
下一篇:添加記錄時的mvc通知
