Bad Request - Invalid Hostname with Asp.net WebAPI project in Visual Studio 2013

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


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