简体   繁体   English

OData WCF连接被拒绝

[英]OData WCF connection refused

i've just written a very simple WCF service that exposes a SQL Server database with OData. 我刚刚编写了一个非常简单的WCF服务,该服务使用OData公开了SQL Server数据库。 i can connect to the service, and make requests using "http://localhost:3006" but cannot connect using the ip address, even on the local machine. 我可以连接到该服务,并使用“ http:// localhost:3006”发出请求,但即使在本地计算机上也无法使用IP地址进行连接。

i followed these basic steps to set up the WCF service and added the JSONP library from MSDN with no issue: http://www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIncludingXMLAndJSONIn30Minutes.aspx 我遵循以下基本步骤来设置WCF服务,并从MSDN添加了JSONP库,没有任何问题: http : //www.hanselman.com/blog/CreatingAnODataAPIForStackOverflowIn includedXMLAndJSONIn30Minutes.aspx

i've checked my firewall logs and found nothing suggesting any problems, although the firewall shouldn't even be in question when connecting to my own local IPv4 address. 我检查了防火墙日志,没有发现任何问题,尽管在连接到我自己的本地IPv4地址时防火墙甚至都没有问题。 the windows firewall is disabled, and can't be the issue. Windows防火墙已禁用,不会成为问题。 i saw this line in the web.config: 我在web.config中看到了这一行:

<!--
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
-->

and commented it out, as you can see, but it didn't fix the issue. 并将其注释掉,如您所见,但这并不能解决问题。 how can i connect to this debug server from a remote machine? 如何从远程计算机连接到此调试服务器?

i was able to solve this problem by doing the following: 我能够通过执行以下操作解决此问题:

perform Windows Update (just do it). 执行Windows Update(只需这样做)。
update to Visual Studio 2010 SP1. 更新到Visual Studio 2010 SP1。
get the IIS Express application. 获取IIS Express应用程序。
in VS, right-click the project node and click "Use IIS Express..." 在VS中,右键单击项目节点,然后单击“使用IIS Express ...”
in the IIS Express applicationhost.config file you will have a site list in the xml 在IIS Express applicationhost.config文件中,您将在xml中有一个站点列表
under the site node that references your project, the binding needs to be changed to this: 在引用您的项目的站点节点下,需要将绑定更改为此:

<binding protocol="http" bindingInformation=":[preferredport]:" />

where [preferredport] should be the port number you want to use. 其中[preferredport]应该是您要使用的端口号。
at the command line, type this to tell httpsys to listen on all ipv4 addresses: 在命令行中,键入以下命令告诉httpsys在所有ipv4地址上进行侦听:

netsh http add iplisten 0.0.0.0

for ipv6, use this line: 对于ipv6,请使用以下行:

netsh http add iplisten ::

run the project from VS2010 and you should now be able to connect remotely. 从VS2010运行项目,您现在应该可以远程连接了。

this was so much less hassle with Linux rest... seems like something that should have been built in, as devs will obviously want to debug using remote clients... 这与Linux休息相比没有那么麻烦...似乎应该被内置,因为开发人员显然希望使用远程客户端进行调试...

it may be possible to do this without IIS Express but i'm not sure how you would configure the VS debug server with the appropriate bindings, but this method does the trick without using Fiddler or WebMatrix or any of that other fluffy stuff. 在没有IIS Express的情况下可能可以执行此操作,但是我不确定如何使用适当的绑定配置VS调试服务器,但是这种方法可以在不使用Fiddler或WebMatrix或其他任何蓬松材质的情况下完成操作。

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

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