I'm trying to define an alias to localhost in development ambient in Visual Studio 2013.
When I used previous versions of Visual Studio, I used the Visual Studio Development Server to debug and the only thing I needed to do was to change my hosts file adding this entry:
127.0.0.1 localhost
127.0.0.1 localhostalias
I'm having problems to do this with VS2013. I've browsed all over the internet and I've tried the following things, but I'd like someone of you to tell me what am I doing wrong. I've obviously already changed the hosts file...
In the web project Properties -> Web in the section Servers where IIS Express is selected as default, I tried changing http://localhost:53944
to http://localhostalias:53944
but an error is showed saying: "Unable to create the virtual directory. Cannot create the Web site 'http://localhostalias:53944'. You must specify "localhost" for the server name
".
I also tried changing the applicationhost.config which is located in <>\IISExpress\config to
<site name="<<Site name>>" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="<<Site Path>>" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:53944:*" />
</bindings>
</site>
And when I opened the project it was changed to
<site name="<<Site name>>" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="<<Site Path>>" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:53944:*" />
</bindings>
</site>
<site name="<<Site name>>(1)" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="<<Site Path>>" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:53944:localhost" />
</bindings>
</site>
Can someone help me?
Thanks in advance,
Camilo
Configure IIS express on visual studioSelect the web application project and open properties -> select the web tab -> under server's select IIS express-> Specify the project URL. Now open the project folder and . vs folder (Hidden) -> Config -> applicationhost.
IIS Express uses a default, user-specific ApplicationHost. config file to allow many users to share the same computer without interfering with other user's settings. This file is located in the %userprofile%\Documents\IISExpress\config folder or %userprofile%\My Documents\IISExpress\config folder, depending on your OS.
If you reach this page looking for a solution for VS2015+, the applicationhost.config
file you are looking for is no longer on documents\IISExpress\config
.
The new location is {solutiondir}\.vs\config\applicationhost.config
.
Since the linked URL from Jack's answer is currently not working, and the solution (at least for me) was covered in the answer to another question, I will repeat the answer here:
You can have multiple bindings set. Therefore, you can setup bindings for every external address you wish to serve on, and it will work:
<bindings>
<binding protocol="http" bindingInformation=":1904:" />
<binding protocol="http" bindingInformation=":1904:machineName" />
<binding protocol="http" bindingInformation=":1904:10.1.10.123" />
</bindings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With