【问题标题】:IIS Express + Visual Studio 2010 + non-local Project UrlIIS Express + Visual Studio 2010 + 非本地项目 URL
【发布时间】:2012-03-30 19:26:07
【问题描述】:

我正面临与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?

【问题讨论】:

    标签: visual-studio-2010 iis-express


    【解决方案1】:

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

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

    您需要编辑 applicationhost.xml

    找到&lt;sites&gt; 部分并扩展:

            <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>
    

    注意 80 端口不能被 IIS 占用,以防它在你的开发盒上运行。

    这个解决方案面临的问题是,这些设置在 VS 中按 F5,或者从 VS 启动网站总是希望在 localhost 上启动,并且不会初始化其他绑定。您必须使用以下命令手动启动 IISExpress:

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

    【讨论】:

    • 非常感谢,最后一件事(手动启动 IIS)为我解决了一切问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-23
    • 2014-09-24
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多