Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Request - Invalid Hostname - Host files already fixed

According to other SO questions the problem has been solved by editing the hosts file and applicationhost file. These two files are already properly setup on my machine. This error started ocurrring right after I upgraded to visual studio 2015 SP1

http://bdtest.localhost:50119/ returns bad request

Hosts File -

localhost name resolution is handled within DNS itself.

127.0.0.1 localhost

::1 localhost

127.0.0.1 bdtest.localhost

application hosts file

<site name="BizDox.Web" id="2">
    <application path="/" applicationPool="Clr4ClassicAppPool">
      <virtualDirectory path="/" physicalPath="C:\Source\BizDox\Summer2015-Navigation\BizDox.Web" />
    </application>
    <bindings>
      <binding protocol="http" bindingInformation="*:50119:*"/>
      <binding protocol="http" bindingInformation="*:50119:localhost" />
      <binding protocol="http" bindingInformation="*:50119:bdtest.localhost" />
      <binding protocol="http" bindingInformation="*:50119:demo.localhost" />
      <binding protocol="http" bindingInformation="*:50119:diy.localhost" />
      <binding protocol="http" bindingInformation="*:50119:akuity.localhost" />
      <binding protocol="http" bindingInformation="*:50119:owlsfactory.localhost" />
      <binding protocol="http" bindingInformation="*:50119:rtp.localhost" />
      <binding protocol="http" bindingInformation="*:50119:barebones.localhost" />
      <binding protocol="http" bindingInformation="*:50119:sygnet.localhost" />
      <binding protocol="http" bindingInformation="*:50119:firstsolution.localhost" />
    </bindings>
  </site>  

What else could cause a 400 error if your host files are properly setup?

I am running VS2015 as admin.

like image 343
Adrian Avatar asked Dec 29 '25 18:12

Adrian


1 Answers

VS 2015 changes the default applicationhost.config file located in mydocuments/iisexpress to be a project specific applicationhost.config file. You can find this in your web project under a hidden .vs folder.

Your two options are to either open this folder and edit the applicatoinhost.config file or to tell the .proj file to use the default config file located in documents/iisexpress. You simply have to alter/add this line to the .proj file.

<UseGlobalApplicationHostFile>true</UseGlobalApplicationHostFile>

Add this to the top of the file inside the <PropertyGroup> tag

Make sure to close VS and re-open it for changes to take effect. Also make sure to run as administrator.

like image 180
Adrian Avatar answered Dec 31 '25 17:12

Adrian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!