原本WCF只使用了< BasicHttpBinding >,现在新增net.tcp协议,添加后服务器报错找不到具有绑定 NetTcpBinding 的终结点的与方案 net.tcp 匹配的基址。注册的基址方案是 [http]。,检查Web.config与网站配置之后依旧报错。
最后参照 WCF:如何将net.tcp协议寄宿到IIS,在网站->绑定->添加net.tcp协议 ,情况解决。


如果刚开始配置,不要忘记在高级设置中增加net.tcp协议

Web.config配置文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
</system.web>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" sendTimeout="00:30:00" transferMode="Streamed">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="WcfMySqlService.MysqlInfo">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="WcfMySqlService.IMysqlInfo">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8084/WcfMysqlService/MysqlInfo.svc"/>
<add baseAddress="net.tcp://localhost:8084/WcfMysqlService/MysqlInfo.svc"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
<add scheme="net.tcp" binding="netTcpBinding" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
若要在调试过程中浏览 Web 应用程序根目录,请将下面的值设置为 True。
在部署之前将该值设置为 False 可避免泄露 Web 应用程序文件夹信息。
-->
<directoryBrowse enabled="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
本文介绍了解决WCF服务配置中引入Net.TCP协议所遇到的问题的过程。通过正确配置Web.config文件并确保IIS中正确绑定Net.TCP协议,最终解决了服务器报错的问题。文章还提供了详细的配置示例。
6515

被折叠的 条评论
为什么被折叠?



