Exposing and testing your local web solutions online using NGrok
We’ve been using Web Hooks lately to try the new Microsoft ASP.NET Web Hooks implementation in action through Visual Studio.
The problem with testing and debugging such a solution is that it expects a URL to connect to, and while in production or on test location it’s not a problem, testing and debugging it on your local machine through Visual Studio in development it is a problem because we don’t have a public facing URL.
To be able to have a public facing URL, we need some kind of tunnel and a public address to our local machine.
For this we can use a great free tool NGrok.
What it does is, when you fire it up, it brings up a random URL to the local URL you point it to, and in a very simple way, opens your local machine to the public world.
In case you opt for a commercial version of the great product, you can have predefined subdomains instead of random ones.
We can use this for example to test Web Hooks receivers in a way that we register this public facing URL to one of the services online like GitHub, Instagram, Slack and others and then receive Web Hook calls directly to our machine.
To use this with Visual Studio, click F5 in your solution which will open your local application in the browser.
Download the NGrok tool which is a simple *.exe program.
Now if the URL of the application is for example: https://localhost:5007
then the command for NGrok in the command line would be:
c:\utils\ngrok\ngrok.exe http 50007 -host-header=”localhost:5007″
This opens up a window like this:
And after this is opened, we and everyone else can access our application through e.g. 7410fb7b.ngrok.io
As long as this command line application is opened.
And that is it, hope it helps!
Got a project?
Let's talk.
Like what you see?
Or have a project, idea, requirement or scope.