How to enable external request in IIS Express?
How can I enable remote requests in IIS Express? Scott Guthrie wrote that is possible but he didn't say how.
There's a blog post up on the IIS team site now explaining how to enable remote connections on IIS Express. Here is the pertinent part of that post summarized:
On Vista and Win7, run the following command from an administrative prompt:
netsh http add urlacl url=http://vaidesg:8080/ user=everyone
For XP, first install Windows XP Service Pack 2 Support Tools. Then run the following command from an administrative prompt:
httpcfg set urlacl /u http://vaidesg1:8080/ /a D:(A;;GX;;;WD)
There are three changes you might need to make.
- Tell IIS Express itself to bind to all ip addresses and hostnames. In your
.config
file. Typically:- VS 2015:
$(solutionDir)\.vs\config\applicationhost.config
- < VS 2015:
%userprofile%\My Documents\IISExpress\config\applicationhost.config
- VS 2015:
Find your site's binding element, and add
<binding protocol="http" bindingInformation="*:8080:*" />
- Setup the bit of Windows called 'http.sys'. As an administrator, run the command:
netsh http add urlacl url=http://*:8080/ user=everyone
Where everyone
is a windows group. Use double quotes for groups with spaces like "Tout le monde".
-
Allow IIS Express through Windows firewall.
Start / Windows Firewall with Advanced Security / Inbound Rules / New Rule...
Program
%ProgramFiles%\IIS Express\iisexpress.exe
OR Port 8080 TCP
Now when you start iisexpress.exe
you should see a message such as
Successfully registered URL "http://*:8080/" for site "hello world" application "/"
Nothing worked for me until I found iisexpress-proxy.
Open command prompt as administrator, then run
npm install -g iisexpress-proxy
then
iisexpress-proxy 51123 to 81
assuming your Visual Studio project opens on localhost:51123 and you want to access on external IP address x.x.x.x:81
Edit: I am currently using ngrok
I remember running into the same problems while trying this workflow a few months ago.
Which is why I wrote a simple proxy utility specifically for this kind of scenario: https://github.com/icflorescu/iisexpress-proxy.
Using the IIS Express Proxy, it all becomes quite simple – no need to “netsh http add urlacl url=vaidesg:8080/ user=everyone” or to mess up with your “applicationhost.config”.
Just issue this in command prompt:
iisexpress-proxy 8080 to 3000
…and then you can point your remote devices to http://vaidesg:3000.
Most of the times simpler IS better.