Enable external request on IIS Express

I was working on Asp.net MVC application and had to test it from another machine. By default, IIS Express doesn’t allow remote connections and you will get an error ‘Bad Request – Invalid Host Name’ .In this post, I will explain how to enable external access to IIS express

Step 1 : Configure IIS Express


For Visual Studio 2015,  open file <solution>/.vs/config/applicationhost.config and localhost in ‘bindingInformation’ to ‘*’.  After making changes, it should like below

HTTP Binding

Step 2: Allow URL Access


  • Open command prompt in ‘Administrator’ mode
  •  Run following command
netsh http add urlacl url=http://*:51603/ user=everyone

Note: Run this command with your IIS listening port. In my case above, application was listening on port 51603

Step 3: Configure Firewall Port


  •  Go to the “Control Panel\Windows Firewall”
  • Click “Advanced settings”
  •  Select “Inbound Rules”
  • Click on “New Rule …” button
  • Select “Port”, click “Next
  • Fill your IIS Express listening port number, click “Next”

Inbound Rule

  • Select “Allow the connection”, click “Next”
  • Check where you would like allow connection to IIS Express (Domain, Private, Public), click “Next”
  • Enter rule name and click “Finish”

 

IMPORTANT: For latest version of visual studio, please read solution details in comments below