问题描述
我有一个 ASP .NET Web 应用程序项目 Visual Studio 2013,我仅将其用于测试目的.我正在使用几乎默认的项目设置:
I have an ASP .NET Web Application project Visual Studio 2013, which I use for testing purposes only. I'm using pretty much the default project setup:
- 运行该项目会启动 IIS Express Web 服务.
- Web 应用程序仅接受来自
localhost
的请求 - 其他主机会导致Bad Request - Invalid Hostname
响应.
- Running the project starts an IIS Express web service.
- The web application only accepts requests from
localhost
- other hosts results in aBad Request - Invalid Hostname
response.
我希望能够发送请求并接收来自 LAN 上另一台机器的响应.我发现这可以通过修改 %USERPROFILE%\Documents\IISExpress\config\applicationhost.config
文件来启用,更改 //configuration/system.conf 文件的值.applicationHost/sites/site/bindings/binding[@bindingInformation]
属性从 *:1728:localhost
到 *:1728:*
.
I want to be able to send requests and recieve responses from another machine on my LAN. I was able to figure out that that this can be enabled by modified %USERPROFILE%\Documents\IISExpress\config\applicationhost.config
file, changing the value of the //configuration/system.applicationHost/sites/site/bindings/binding[@bindingInformation]
attribute from *:1728:localhost
to *:1728:*
.
这可行,但还有另一个烦人的问题:每当我在 Visual Studio 中重新打开项目时,都会在 applicationHost.config
文件中创建一个重复的 site
元素,并使用旧的*:1728:localhost
为 bindingInformation
属性的值,这意味着我必须重复上述过程.有没有办法让 IIS Express/Visual Studio 使用现有的、修改过的 site
配置元素而不是创建一个新的配置元素?如果失败,有没有办法将 bindingInformation
属性的默认值更改为 *:1728:localhost
而不是 *:1728:localhost
?
This works, but there's another annoying problem: Whenever I reopen the project in Visual Studio, a duplicate site
element is created in the applicationHost.config
file with the old value of *:1728:localhost
for the bindingInformation
attribute, meaning I have to repeat the above process. Is there a way to get IIS Express/Visual Studio to use the existing, modified site
configuration element rather than create a new one? Failing that, is there a way to change the default value for the bindingInformation
attribute to *:1728:localhost
instead of *:1728:localhost
?
推荐答案
不要从 :1728:localhost 中删除 localhost.只需复制 :1728:localhost;:1728:192.168.1.1
Do not remove localhost from :1728:localhost.Just duplicate :1728:localhost; :1728:192.168.1.1
这篇关于打开 ASP .Net Web App 项目时,防止将重复的站点元素添加到 applicationHost.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!