Ngrok没有将我的帖子请求传递给localhost

时间:2017-10-26 06:48:26

标签: asp.net-mvc webhooks ngrok stripe.net

我正在尝试为Stripe设置webhook,并且我已经根据Stripe doc创建了一个控制器,以便在虚拟机中运行的ASP.Net MVC中执行此操作(可能)改变了什么?)。我一直在测试控制器中的操作以查看我是否可以收到帖子,因此我使用Postman发送我的localhost帖子请求正在运行。但现在我需要使用Ngrok为我的localhost提供一个url,以便Stripe可以使用它。我正在运行ngrok并传入这些参数来运行

ngrok http -host-header="localhost:44368" 44368

这是我看到的,一切看起来都不错

enter image description here

但现在我尝试在Postaman中使用它

  

ex https://11d1ba97.ngrok.io/StripeWebHook/Index

我收到502 Bad Gateway消息,操作方法永远不会被命中。

当我尝试从Stripe发送测试webhook时遇到同样的问题。 仅供参考 - 来自Ngrok的请求时间使用' localhost:4040'将我的所有响应时间显示为0ms。

enter image description here

更新 - 我收到了ngrok的电子邮件 "麻烦就是HTTPS。 ngrok终止HTTPS流量,然后将未加密的http流量转发到您的本地应用程序。你想做两件事之一:

1)使您的应用程序也公开HTTP端口并将流量转发给该端口 2)使用ngrok的TLS隧道(TLS流量交给你终止)。使用此选项,您可以完成执行证书管理,证书不匹配等所有复杂性,只需fyi。如果可能,我建议#1;#34;

问题 - 有人知道如何使用Https打开ASP.Net MVC应用程序中的http端口吗?

2 个答案:

答案 0 :(得分:5)

我的问题是我的应用程序中的断点没有被击中。

我正在使用

ngrok http 58533

但是将其更改为以下内容可以让我的断点受到攻击。

ngrok http -host-header=rewrite localhost:58533

答案 1 :(得分:3)

晚点参加聚会:) 我可以通过取消选中“属性”中的“启用SSL”标志来使http工作。

步骤1:右键单击“ Web Api”项目,选择“属性” enter image description here

第2步:下载并安装扩展程序

https://marketplace.visualstudio.com/items?itemName=DavidProthero.NgrokExtensions

第3步:从Visual Studio启动ngrok隧道

enter image description here

(来自https://raw.githubusercontent.com/dprothero/NgrokExtensions/master/docs/img/menu-item.png的图片)

第4步:复制转发http网址

enter image description here

第5步:粘贴Postman,然后附加控制器/操作

enter image description here

您得到200! (赞?:))

相关问题