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. I'm only trying to deploy the MVC starter code from VS. I've registered a domain on the ngrok website, but how do I get my app to point to that domain?
Ngrok is device-based software that makes it clear that you can run a localhost web page on another device to provide a link to anyone to direct to the specific local host hosted on the device.
ngrok Secure Tunnels allow you to instantly open access to remote systems without touching any of your network settings or opening any ports on your router. This means you get a secure, reliable tunnel for your developer box, IoT device, or just about anything that has access to the internet.
There is a new open source WPF application that makes it easier to setup ngrok. Check it out here. https://github.com/devinrader/ngrok.editor. Prerequisite: You'll need to have some way to run the WPF application. The instructions immediately below should still be valid.
NOTE: Make sure that Visual Studio is running in Administrator mode. Otherwise, ngrok may not be able tunnel to your local server
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. Copy that port name because we'll use it in a bit.
Navigate to %userprofile%\documents\iisexpress\config\
. To navigate here, just copy the address above and paste it into your address bar. Open the file 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)
In that document, locate the website you want to expose through ngrok by searching for the port number. 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.
Run visual studio so that your local server is running. Run ngrok using the same port number, ####
. 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:
<bindings>
<binding protocol="http" bindingInformation="*:####:localhost" />
<binding protocol="http" bindingInformation="*:####:[YOUR_NGROK_URL]" />
</bindings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With