当我编译我的项目时,它在 url http://localhost:12421/index.html 中运行
我可以在我的私有 ip 中运行它吗?让我们说http://192.168.1.212:12421/index.html 我试图浏览它,它给了我错误错误请求 - 无效的主机名
HTTP 错误 400。请求主机名无效。
例如,我有一个ASP.NET名为myWebSite的项目。
以下将http://localhost:12421/ 服务器地址更改为IP地址的方法例如: 192.168.1.7:80总是对我有用。

c:\Windows\system32>netsh http add urlacl url=http://192.168.1.7:80/ user=everyoneEnterURL reservation successfully added
C:/Users/UserName/Documents/IISExpress/config/并打开applicationhost.config。applicationhost.config文件中找到您的站点部分<sites>。<sites>
<site name="myWebSit" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\myWebSit\myWebSit" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:12421:localhost" />
</bindings>
</site>
</sites>
Run Code Online (Sandbox Code Playgroud)
现在将地址更改为您的 IP localhost。例如:
<binding protocol="http" bindingInformation="*:80:192.168.1.7" />
Run Code Online (Sandbox Code Playgroud)
properties。在属性中选择选项Web卡,然后将项目 URL文本框内容更改为您的地址。例如:http://192.168.1.7:80/然后单击Create Virtual Directory按钮。The virtual directory was created successfully.消息。
现在,您应该能够通过自己的 IP 地址在 Visual Studio 中运行您的项目。
| 归档时间: |
|
| 查看次数: |
9596 次 |
| 最近记录: |