2

First of all, I have managed this before on another machine using VS 2012 and Windows 8. The only difference I can see with this machine is that I am using VS 2013.

So, I have set up my host file to have this:

127.0.0.1   localhost
127.0.0.1   localhost:3892

127.0.0.1   r3plica.localhost
127.0.0.1   r3plica.localhost:3892

On my working machine the localhost:3892 doesn't exist and it works without it. In visual studio everything is set as default. When I f5 the browser goes to localhost:3892 and everything works as expected.

On my other machine, if I change the URL to r3plica.localhost:3892 the expected website loads and I can still debug it (debugging is what I need to do).

On my new machine if I change to the new URL I get a Bad Request error.

I have searched the internet and can not find the solution, so if anyone has had the same issue, please help me fix it! :D

Cheers,
/r3plica

r3plica
  • 13,017
  • 23
  • 128
  • 290
  • Have had the exact same problem. Worked in VS2012 on Windows 8. Upgraded to VS2013, made no other changes, and now I get the Bad Request error when I go to mysubdomain.localhost:55079 – Steve Kennaird Feb 03 '14 at 08:49

1 Answers1

4

I managed to solve this issue by:

  • Running Visual Studio in admin mode
  • Forcing IIS Express to run in admin mode too (locate iisexpress.exe in C:\Program Files (x86)\IIS Express\, right click and select Properties then Compatibility tab then tick the 'Run this program as an administrator' checkbox).
  • Modifying the applicationhost.config file for IISExpress for the site you're debugging. The file can be found at Documents > IISExpress > config. Find the relevant site node and change the bindingInformation attribute to the below (but putting your port number in):

    <site name="MyWebsite.UI" id="52">
        <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\Dev\Code\Latest\MyWebsite.UI" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:55079:*" />
        </bindings>
    </site>
    

Note the bindingInformation attribute value is:

*:{PortNumber}:*

instead of:

*:{PortNumber}:localhost
Community
  • 1
  • 1
Steve Kennaird
  • 1,604
  • 13
  • 21
  • What if the website I'm working on doesn't seem to appear there? – Shimmy Weitzhandler Aug 10 '15 at 11:29
  • Not had that issue before, so I'm not sure. What version of VS are you using - if it's VS2015, I think things have changed and the config file is placed within the project now (though haven't looked at this in detail yet) – Steve Kennaird Aug 10 '15 at 15:01
  • The location of the config files is not the issue. My issue is I don't seem to find my project in the `applicationhost.config` file. – Shimmy Weitzhandler Aug 10 '15 at 19:00