I am running a very basic webAPI project in Visual Studio Pro 2013. It runs fine on localhost on my machine. I then try and go to a browser from a different machine and goto
Another thing that helped me is to add 127.0.0.1
to the binding.
So the result applicationhost.config
looks like this:
<bindings>
<binding protocol="http" bindingInformation="*:28066:" />
<binding protocol="http" bindingInformation="*:28066:localhost" />
<binding protocol="http" bindingInformation="*:28066:127.0.0.1" />
<binding protocol="http" bindingInformation="*:28066:sitename.com" />
<binding protocol="https" bindingInformation="*:44302:" />
<binding protocol="https" bindingInformation="*:44302:localhost" />
<binding protocol="https" bindingInformation="*:44302:127.0.0.1" />
<binding protocol="https" bindingInformation="*:44302:sitename.com" />
</bindings>
And hosts
file is like this:
127.0.0.1 localhost
127.0.0.1 sitename.com
Before adding 127.0.0.1
it was OK in the browser to navigate like https://localhost:44302
, but https://sitename.com:44302
resulted in Bad Request
.
Also, if you do the 'hot-replacement', make sure you're reseting IIS. You can do that by right-clicking on the project in the Visual Studio, selecting Unload project
, then change applicationhost.config
, save it, and Reload project
in VS.
By the way, don't forget to generate SSL certificate for your project. I'm not sure that Visual Studio will do that for you.
Port should be in range from 44300 to 44399.
Here's how you can generate SSL:
makecert -r -pe -n CN="dev.helpme.transwestern.com" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localmachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12
netsh http show sslcert ipport=0.0.0.0:44302
(you will need to get appid from this step)netsh http delete sslcert ipport=0.0.0.0:44302
Now, open "Manage computer certificates", navigate to the Personal and select newly created. You will need "Details/Thumbprint".
netsh http add sslcert ipport=0.0.0.0:44302 certhash=<thumbprint> appid={id from step 3}
(include bracets {})Hope that helps.
Here is how I got it to work.
goto C:\users\yourusername\Documents\IISExpress\config\applicationhost.config in Visual Studio 2013
Add the following line to applicationhost.config made it to work
<binding protocol="http" bindingInformation="*:53676:*" />
where this didn't work
<binding protocol="http" bindingInformation="<clientsIPaddress>:53676:*" />
Vs2015 Update and the exact location for this change the application.config are outlined below.
The path to the file is the following for VS 2015.
C:\Users\\{YourUsername}\Documents\Visual Studio 2015\Projects\\{ThisSolutionName}\\.vs\config\applicationhost.config
as Daniel mentioned.
Where do I put this in my application.config?
Below are the parent sections in the XML file where you would find the bindings.
<system.applicationHost>
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
This was roughly line 161 for a new project that didn't change anything in the applicationhost.config.
What I didn't realise is what I thought the clients IP address was, actually wasn't true. The reason being is that I had a VNet to VNet connection in Azure and the gateway that is connecting the two IP addresses reassigns the clients IP address on the network in which my application was running. I thus had to look up the new IP address it was mapped to in order to not use the *:port:*
strategy
Had the same issue for an hour, tried everything here and related to this problem, but what fixed it was running Visual Studio as Administrator. Otherwise I'd keep getting Unable to connect to web server 'IIS Express'
error which leads you in the wrong way.
I can not comment, but wanted to answer @EthanKeiser
Visual Studio 2015 has a separate config file for each Solution that you will need to update per the accepted answer. This file is located at:
C:\Users\\{UserName}\Documents\Visual Studio 2015\Projects\\{SolutionName}\\.vs\config\applicationhost.config