Skip to content

Instantly share code, notes, and snippets.

@nsbingham
Last active December 18, 2020 20:29
Show Gist options
  • Save nsbingham/9548754 to your computer and use it in GitHub Desktop.
Save nsbingham/9548754 to your computer and use it in GitHub Desktop.
How to get ngrok working with IISExpress/Visual Studio 2013
  1. Decide on a subdomain to use with ngrok. This makes the whole process easier.
  2. Open up a Command Prompt in Administrator mode and run the following command to register the URL with HTTP.sys replacing "modernie" with your subdomain and ##### with your VisualStudio/IISExpress application's port.
netsh add urlacl url=http://modernie.ngrok.com:##### user=everyone
  1. Edit your applicationhost.config. The easiest way to is start up the site and right-click the IISExpress icon in the System Tray. Click "Show All Applications" and select your website running at localhost:#####. Click the path next to "Config" to open the file in an editor.
  2. Search for you site's <bindings> configuration. The easiest way is to search for *:#####:localhost, which should bring you to the <bindings> section for your site. Edit them to include the following:
<bindings>
  <binding protocol="http" bindingInformation="*:#####:modernie.ngrok.com" />
  <binding protocol="http" bindingInformation="*:#####:localhost" />
</bindings>

Save the file, making sure to replace "modernie" with your subdomain and ##### with your application's VisualStudio/IISExpress port.

  1. Restart your site.
  2. Run ngrok with the subdomain settings from a Command Prompt running in Administrator mode. This can be done with the following command:
ngrok.exe -authtoken XXXXXXXXXXXXXXXXXXXX -subdomain=modernie #####

Make sure to replace "modernie" with your subdomain and ##### with your application's VisualStudio/IISExpress port.

@dprothero
Copy link

@ProNotion and everyone, I built a Visual Studio extension to make this easier. Please let me know what you think:
https://visualstudiogallery.msdn.microsoft.com/56a642ed-a5e0-4044-8735-740d36912c5e

@RefractedPaladin
Copy link

@moranm6 did you ever solve this? I also need this solution so I can convince "management" to pay for this tool.

@ProNotion
Copy link

@dprothero It works a treat - thanks so much for taking the time and for sharing. I'm still curious - why I can't get it work from the command line myself anymore but thanks for a great extension!

@tscbp
Copy link

tscbp commented Sep 12, 2018

Tried dprothero's command above, as well as the extension. Tried netsh and editing applicationhost.config. In every case, what I get when I try to visit the ngrok url is:

a) in my ngrok client, I see the request come in - so it is getting to my machine
b) the request takes quite a while - ballpark 2 minutes?
c) eventually comes back 502

seemingly same as this StackOverflow article

Anyone else running into this with VS2017?

@BitWizJason
Copy link

@tscbp The latest version of ngrok resolves the issue see inconshreveable/ngrok#448 and my answer at the SO article you mentioned: VS 2017 IIExpress ngrok SO Article

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment