简体   繁体   English

如何在ngrok上部署visual studio项目?

[英]How do I deploy a visual studio project on ngrok?

I'm trying to build deploy an ASP.NET app in C# using ngrok rather than a on a web server, but I'm running into errors every time I do so. 我正在尝试使用ngrok而不是在Web服务器上构建在C#中部署ASP.NET应用程序,但每次我都会遇到错误。 I'm only trying to deploy the MVC starter code from VS. 我只是尝试从VS部署MVC入门代码。 I've registered a domain on the ngrok website, but how do I get my app to point to that domain? 我在ngrok网站上注册了一个域名,但如何让我的应用程序指向该域名?

EDIT: 编辑:

There is a new open source WPF application that makes it easier to setup ngrok. 有一个新的开源WPF应用程序,可以更容易地设置ngrok。 Check it out here. 在这里查看。 https://github.com/devinrader/ngrok.editor . https://github.com/devinrader/ngrok.editor Prerequisite: You'll need to have some way to run the WPF application. 先决条件:您需要有一些方法来运行WPF应用程序。 The instructions immediately below should still be valid. 紧接下面的说明仍然有效。


NOTE: Make sure that Visual Studio is running in Administrator mode. 注意:确保Visual Studio以管理员模式运行。 Otherwise, ngrok may not be able tunnel to your local server 否则,ngrok可能无法隧道到您的本地服务器

First, you'll need the name of the port that you are deploying to. 首先,您需要部署到的端口的名称。 Run and deploy your solution, then look at the address bar. 运行并部署您的解决方案,然后查看地址栏。 You should see an address like this, localhost:#### , where #### is your port name. 您应该看到这样的地址localhost:#### ,其中####是您的端口名称。 Copy that port name because we'll use it in a bit. 复制该端口名称,因为我们会稍微使用它。

Navigate to %userprofile%\\documents\\iisexpress\\config\\ . 导航到%userprofile%\\documents\\iisexpress\\config\\ To navigate here, just copy the address above and paste it into your address bar. 要在此处导航,只需复制上面的地址并将其粘贴到地址栏中即可。 Open the file applicationhost.config . 打开文件applicationhost.config (You may need to be running as an administrator. To do so, locate your VS application, right click, and then select run as administrator) (您可能需要以管理员身份运行。要执行此操作,请找到您的VS应用程序,右键单击,然后选择以管理员身份运行)

In that document, locate the website you want to expose through ngrok by searching for the port number. 在该文档中,通过搜索端口号找到要通过ngrok公开的网站。 Then add this: < binding protocol="http" bindingInformation="*:####:[YOUR_NGROK_URL]" /> Be sure to replace #### with the port number you copied earlier and to replace [YOUR_NGROK_URL] with your ngrok URL. 然后添加: < binding protocol="http" bindingInformation="*:####:[YOUR_NGROK_URL]" />请务必将####替换为您之前复制的端口号,并将[YOUR_NGROK_URL]替换为您的ngrok网址。

Run visual studio so that your local server is running. 运行visual studio以便本地服务器正在运行。 Run ngrok using the same port number, #### . 使用相同的端口号####运行ngrok。 Then visit the website. 然后访问该网站。 Your site should be up, live and active, running off of your local server. 您的站点应该启动,生存和活动,运行本地服务器。

The <bindings> tag in applicationhost.config should end up looking like this: applicationhost.config中的<bindings>标签最终应该如下所示:

<bindings>  
    <binding protocol="http" bindingInformation="*:####:localhost" />  
    <binding protocol="http" bindingInformation="*:####:[YOUR_NGROK_URL]" />  
</bindings>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用类似MSI的安装程序部署Visual Studio插件? - How do I deploy a Visual Studio addin with an installer like MSI? 如何在Visual Studio C中创建“项目概述”# - How do I create a “Project overview” in Visual Studio C# 如何在Visual Studio中获得通往另一个项目的路径? - How Do I Get The Path To Another Project In Visual Studio? 如何在Visual Studio建模项目上更改目标框架? - How do I change the Target Framework on a Visual Studio Modeling Project? 如何在Visual Studio中正确显示MVC项目? - How do I make a MVC project appear properly in Visual Studio? 如何使用Visual Studio项目中包含的文件? - How do I use a file included in my visual studio project? 如何在 Visual Studio 2019 中创建 SwCsharpAddin 项目? - How do I create the SwCsharpAddin project in Visual Studio 2019? 如何在Visual Studio 2010中使用我的设置和部署项目部署SQL Server数据库? - How can I deploy the SQL server database with my setup and deployment project in Visual Studio 2010? 当我在Visual Studio中创建项目引用时,我是否必须在部署时包含这些项目的DLL? - When I make a project reference in Visual Studio, do I then have to include the DLLs for those projects when I deploy? 如何使用 Visual Studio 2010 部署基于 Crystal Reports .Net 的项目? - How to deploy Crystal Reports .Net based project with Visual Studio 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM