简体   繁体   English

在本地LAN上部署ASP.NET Web服务

[英]Deploy ASP.NET webservice on Local LAN

I have just develop a webservice on VS2012 and Build Successful. 我刚刚在VS2012上开发了一个Web服务,并且构建成功。 The link like: 链接如下:

http://localhost:55555/eTradingWebservice.asmx

But when i change this by: 但是当我通过以下方式更改时:

http://127.0.0.1:55555/eTradingWebservice.asmx

-> it return BAD REQUEST - Invalid Hostname on my Google Chrome On the machine is same problem (BAD REQUEST) ->它返回错误请求-我的Google Chrome浏览器上的无效主机名是同一问题(错误请求)

I have checked my hosts file, it contain string: 我已经检查了主机文件,其中包含字符串:

127.0.0.1 locahost

I try to check IIS service, try with this link: 我尝试检查IIS服务,请尝试使用此链接:

http://localhost
http://127.0.0.1

every is OK. 一切都很好。 I deploy my project on IIS8 with VS2012 我使用VS2012在IIS8上部署我的项目

The problem is caused by IIS Express not having any binding for 127.0.0.1 for your web service project and only having binding for localhost in the applicationhost.config file. 此问题是由于IIS Express没有为您的Web服务项目提供127.0.0.1的任何绑定,而只有applicationhost.config文件中的localhost的绑定。 You need to add the 127.0.0.1 binding in order to get this to work. 您需要添加127.0.0.1绑定才能使其生效。

The file is locate in [My Documents]\\IISExpress\\Config folder and you need to search for your project bindings and add the 127.0.0.1 as I have done in an example from my machine: 该文件位于[我的文档] \\ IISExpress \\ Config文件夹中,您需要搜索项目绑定并添加127.0.0.1,就像在我的计算机上的示例中所做的那样:

<site name="MVCApp" id="15">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="D:\Projects\MVCApp" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:55555:localhost" />
        <binding protocol="http" bindingInformation="*:55555:127.0.0.1" />
    </bindings>
</site>

You may also need to open that up using netsh: 您可能还需要使用netsh打开它:

netsh http add urlacl url=http://127.0.0.1:55555/  user=everyone 

when you are done you can remove this with 完成后,您可以使用

netsh http delete urlacl url=http://127.0.0.1:55555/

Take a look at Using IISExpress for addresses other than localhost! 看看将IISExpress用于本地主机以外的地址! by 'But it works on my PC!' “但是它可以在我的PC上运行!”

which recommends a final step to run IISExpress with administrative privileges/ You can do this either by running VS as administrtor or by opening a PowerShell prompt with administrative privileges and running the command 建议使用管理权限运行IISExpress的最后一步/您可以通过以管理员身份运行VS或打开具有管理权限的PowerShell提示符并运行命令来执行此操作

C:\Program Files\IIS Express\iisexpress.exe /site:MyWebProject

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM