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
Step 2: Allow URL Access
- Open command prompt in ‘Administrator’ mode
- Run following command
1 |
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”
- 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
Another, simpler option is to use the Visual Studio extension ‘Conveyor’, which does everything for you without touching any configuration files or your project. https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
Makes it easy for testing. Great tool, thanks for sharing.
Only this proxy works for me.
The solution mentioned in this post did not work
Conveyor did the trick for me. Thanks a ton!
I’m using VS 2015 Update 1. When I do exact as this post, It creates another set of “site” elements with localhost. What works for me was adding another binding with ‘*’ or IP address without changing existing binding (have both binding elements).
this! The author should update the article to specify this. otherwise, you’ll have to modify the settings every time you restart the project
Yeah, this worked for me too… the rest of these instructions were golden… this was the only change I made to my configuration.
Hats off to both Sajith and Lakshmi!
WARNING ===> Working with Visual Studio Community 2017… this really screwed things up. Now I can’t get the site to launch at all. Super frustrated. Wished I’d looked at the comments before screwing up my local config by following these instructions.
If you have the local IIS already running then the netsh command for wich IIS will be issued? IIS or IIS express?