After debugging my website in Visual Studio 2015, I can visit it via localhost:50544. I would like to visit my website on a different computer from which it is being served upon that is also on the same network. To do this I should be able to visit that computers address which is 192.168.1.13:50544.
However when visiting this address I get a ‘Bad request, invalid host name’ error. Even if I visit it on the same machine as the website is being served on.
Following the advice here I have created the following windows firewall rule and have also tried turning the firewall off entirely. 
I’m using IIS express and so have added to the ‘~DocumentsIISExpressconfigapplicationhost.config’ file
<binding protocol="http" bindingInformation=":8080:localhost" /> //original rule <binding protocol="http" bindingInformation="*:50544:192.168.1.13" />
But visiting 192.168.1.13:50544 on any machine still results in the ‘Bad Request’ error.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You have to run Visual Studio as Administrator
In Visual Studio 2015 the applicationhost.config is located it the folder in the project itself. Esc MyProjectName.vsconfig, note that the .vs folder may be hidden. Change the Ip from there, not IISExpress folder.
Your <binding protocol="http" bindingInformation="*:50544:192.168.1.13" /> is correct.
Method 2
The format of the bindingInformation attribute is:
ip address:port:host header
What you need is:
bindingInformation="192.168.1.13:50544:*"
Update:
There appear to be some folks who are under the mistaken belief that this answer is incorrect. First of all go read the documentation (see link above) and read the examples.
Secondly IIS and IIS Express are essentially the same product. IIS Express has been tweaked so that non-administrators can run IIS on developer PC’s where they might not have full local admin rights. Despite this, both IIS and IIS Express use the same applicationHost.config file formats, and this means that the bindingInformation attribute format is exactly the same for both products.
The reason that the (incorrect) :50544:192.168.1.13 bindingInformation string works is because (rightly or wrongly):
- if there is no host header specified
- if there is no matching IP address in the first part of the binding info field
… then IIS will try to match to an IP address in the host header part of the binding info string.
The correct format for both IIS7+ and IIS Express is, and always has been:
ip_address:port:host_header
Method 3
We made an extension called Conveyor that you can use to open up IIS Express to external access without any config changes.
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
Method 4
In case someone is still having issues with this, the thing that fixed it for me is running Visual Studio in administrator mode.
I’ve read somewhere that IIS will not let you use anything else than localhost as the host if not in that mode (after editing the config file I was getting error that IIS could not be started)
Also very important as stated by OP, edit the file in your project (%PROJECT%.vs%PROJECT%configapplicationhost.config), not the one in the IIS Express folder…
Method 5
I had same issue with remote access and I tried all of these tips to fix it. For me helped ticking “Allow anonymous authentication” in Web project config.
Method 6
I had everything working fine until today.
- firewall ok
- VS runs in admin mode
applicationhost.configfile ok
I just disabled "Enable Edit and continue" (in csproj) and it stopped working. I enabled it again, and there we go again.
Hope this helps
Method 7
This solution helped me with .net 6 aspNetCore app.
Find a file PropertieslaunchSettings.json
Go to iisSettings->iisExpress->applicationUrl
I replaced my http://localhost:51222/ to http://192.168.1.126:51222/
"iisExpress": {
"applicationUrl": "http://192.168.1.126:51222/",
"sslPort": 44392
}
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0