Exposing and testing your local web solutions online using NGrok

/ Read time 2.5min

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: http://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:

NGrok

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!

Building, architecting and managing large scale web applications on Microsoft platform...but most importantly...putting passion into code ;) CTO @nmdia

Hello from NETMedia, EU based production team delivering high impact projects for selected direct clients, software/web development and digital agencies.

Like what you see? Let's have a chat about the cooperation.

contact us now
 
Cookies help us deliver our services and better user experience. By using our website, you agree to our use of cookies.
OK
More