gpt4 book ai didi

visual-studio-2010 - IIS Express + Visual Studio 2010 + 非本地项目 Url

转载 作者:行者123 更新时间:2023-12-02 00:23:23 24 4
gpt4 key购买 nike

我正面临与 another question 相关的困境但不完全一样。

我想通过自定义 URL 使用 IIS Express,但不修改本地 HOSTS 文件。

具体来说,对我而言,dev.example.com 使用 DNS 解析为 127.0.0.1(我们的 DNS 设置为 *.example.com 解析为 127.0 .0.1).这是我想用作项目 URL 的内容。如果我将 dev.example.com 添加到我的 HOSTS 文件中,它会起作用,但如果我不这样做,它就不会起作用。我猜测这是因为 Visual Studio 无法将其识别为本地 URL。

有没有办法不修改 HOSTS 文件,但仍然使用像 dev.example.com 这样的自定义 URL 作为带有 IIS Express 的 Visual Studio 中的项目 Url?

最佳答案

是的。 IISExpress配置存储在以下执行用户配置文件中:

C:\Users\<username>\Documents\IISExpress\config\

您需要编辑applicationhost.xml

找到 <sites>部分和扩展:

        <site name="WebApplication1" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\inetpub\WebApplication1" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:45965:localhost" />
<binding protocol="http" bindingInformation="*:80:dev.example.com" />
</bindings>
</site>

请注意,IIS 不能占用端口 80,以防它在您的开发箱上运行。

这个解决方案面临的问题是,通过这些设置在 VS 中按 F5,或者以其他方式从 VS 启动网站将始终希望在本地主机上启动,并且不会初始化其他绑定(bind)。您必须使用以下命令手动启动 IISExpress:

c:\Program Files (x86)\IIS Express\iisexpress.exe"/site: WebApplication1

关于visual-studio-2010 - IIS Express + Visual Studio 2010 + 非本地项目 Url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9941504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com