我刚刚创建了一个WCF网站,使用的是.net 3.5。我认为创建默认的网站就足够了,但复制起来却很困难。我有VS2013和所有更新,都是从我的MSDN下载的,我还有Windows 8.1。
我必须说,几个月前,我在一些机器上遇到了这个问题,其他人帮忙解决,我当时以为这是与安装相关的问题,但现在它出现在3台不同的机器上,其中一台是Windows 8,全部都是64位系统。
服务已经完美完成,因为这是我的交付成果,并且在生产中运行得很顺畅。
现在我创建了一个基本的ASP.net,也是.net 3.5。我试图添加服务引用,但失败后显示以下消息。
“下载'http://localhost:40226/HabeasDataService.svc/_vti_bin/ListData.svc/$metadata'时出错。请求失败,HTTP状态为404:未找到。元数据包含无法解析的引用:'http://localhost:40226/HabeasDataService.svc'。远程服务器返回了意外的响应:(405)方法不允许。远程服务器返回了错误:(405)方法不允许。如果服务在当前解决方案中定义,请尝试构建该解决方案并重新添加服务引用。”
当然,我进行了重建和清理操作,但问题仍然存在。
服务的配置如下。
并尝试了两种配置,但仍然出现同样的错误。
我必须说,几个月前,我在一些机器上遇到了这个问题,其他人帮忙解决,我当时以为这是与安装相关的问题,但现在它出现在3台不同的机器上,其中一台是Windows 8,全部都是64位系统。
服务已经完美完成,因为这是我的交付成果,并且在生产中运行得很顺畅。
现在我创建了一个基本的ASP.net,也是.net 3.5。我试图添加服务引用,但失败后显示以下消息。
“下载'http://localhost:40226/HabeasDataService.svc/_vti_bin/ListData.svc/$metadata'时出错。请求失败,HTTP状态为404:未找到。元数据包含无法解析的引用:'http://localhost:40226/HabeasDataService.svc'。远程服务器返回了意外的响应:(405)方法不允许。远程服务器返回了错误:(405)方法不允许。如果服务在当前解决方案中定义,请尝试构建该解决方案并重新添加服务引用。”
当然,我进行了重建和清理操作,但问题仍然存在。
服务的配置如下。
<system.serviceModel>
<services>
<service behaviorConfiguration="ServicesLayer.Service1Behavior"
name="ServicesLayer.Service1">
<endpoint
bindingConfiguration="BigHttpBinding"
name="BasicHttp"
address=""
binding="basicHttpBinding"
contract="ServicesLayer.IHabeasDataService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServicesLayer.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding
name="BigHttpBinding"
maxBufferSize="65536"
maxBufferPoolSize="65536"
maxReceivedMessageSize="65536"
transferMode="Buffered">
<readerQuotas
maxDepth="64"
maxStringContentLength="65536"
maxArrayLength="65536"
maxBytesPerRead="4096"
maxNameTableCharCount="32768"/>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
我注意到了这行代码:
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
并尝试了两种配置,但仍然出现同样的错误。
当我尝试通过在浏览器中点击视图来运行svc文件时,我会收到404.17错误,如下所示。
这非常令人沮丧,因为它完全停滞了开发进程。
注意:与IIS相关的所有内容都可能有用,但请记住它是IIS Express。无论如何切换到本地IIS,仍然失败,但正如我所说,在生产服务器上它是完美的。
bin
或debug
文件夹添加某些参考DLL?或者Windows身份验证/模拟用于任何地方? - Pranav Singh