在IIS Express for Visual Studio中设置本地主机别名 [英] Setting localhost alias in IIS Express for Visual Studio
问题描述
我正在尝试在Visual Studio 2013的开发环境中为localhost定义别名.
I'm trying to define an alias to localhost in development ambient in Visual Studio 2013.
当我使用早期版本的Visual Studio时,我使用Visual Studio Development Server进行调试,我唯一要做的就是添加以下条目来更改主机文件:
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
我在使用VS2013时遇到问题.我浏览了整个互联网,并尝试了以下操作,但是我希望你们中的某人告诉我我在做什么错.我显然已经更改了主机文件...
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...
在Web项目的属性"->服务器"部分的"Web"中,默认选择IIS Express,我尝试将http://localhost:53944
更改为http://localhostalias:53944
,但显示错误消息:"Unable to create the virtual directory. Cannot create the Web site 'http://localhostalias:53944'. You must specify "localhost" for the server name
".
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
".
我还尝试将位于<> \ IISExpress \ config中的applicationhost.config更改为
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>
有人可以帮助我吗?
预先感谢
卡米洛
推荐答案
如果到达此页面以寻找VS2015 +的解决方案,则您要查找的applicationhost.config
文件将不再位于documents\IISExpress\config
上.
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
.
新位置是{solutiondir}\.vs\config\applicationhost.config
.
这篇关于在IIS Express for Visual Studio中设置本地主机别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!