【问题标题】:The protocol 'net.tcp' is not supported不支持协议“net.tcp”
【发布时间】:2010-10-26 11:32:04
【问题描述】:

当我尝试浏览我的 service.svc 文件时,我不断收到此错误。

  1. 我默认启用了 tcp IIS 中的网站。
  2. 端口号 808:* 已经 在我的 IIS 绑定中
  3. 我已经安装了 WAS 并支持 非 http 协议...
  4. TcpChannellistener 服务和 tcp 端口共享服务正在运行..

但是,现在为什么我无法浏览该网站?它一直显示“不支持协议'net.tcp'。”

这是我的代码...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Web.Services.Description;
using System.ServiceModel.Description;
using System.ServiceModel.Channels;
using System.IO;

namespace WcfService7
{
    public class clsMyOwnServiceHost:ServiceHostFactory
    {

               protected override ServiceHost CreateServiceHost( Type t, Uri[] baseAddresses )
               {

                   NetTcpBinding tcpbinding = new NetTcpBinding(SecurityMode.None);
                   BasicHttpBinding basicbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                   WSHttpBinding wsbinding = new WSHttpBinding(SecurityMode.None);

                   baseAddresses = new Uri[] { new Uri("http://localhost/WcfService7/Service1.svc"),new Uri("net.tcp://localhost/WcfService7/Service1.svc/tcp") };
                   ServiceHost host = new ServiceHost(t, baseAddresses);
                   baseAddresses.ToList().ForEach(uri =>
                    {


                        //ServiceMetadataBehavior metabehavior = new ServiceMetadataBehavior();

                        //metabehavior.HttpGetEnabled = true;
                      //  host.Description.Behaviors.Add(metabehavior);
                        if (uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), basicbinding, "basic");
                      if(uri.AbsoluteUri.Contains("net.tcp://"))  host.AddServiceEndpoint(typeof(IService1),tcpbinding,"tcp");
                       if(uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), wsbinding, "ws");
                       if (uri.AbsoluteUri.Contains("http://")) host.AddServiceEndpoint(typeof(IService1), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");



                    });

                   return host;
               }

    }
}

请帮帮我...

非常感谢

【问题讨论】:

  • 您使用的是哪个版本的 IIS? IIS6 不以任何方式、形状或形式支持 net.tcp - 您必须自行托管。 IIS7/7.5支持net.tcp,但需要手动激活
  • 我正在使用 IIS7 并且 TCP 已激活

标签: c# wcf


【解决方案1】:

您需要为您的 uri 添加 TCP 端口。 HTTP 有默认端口,但 TCP 没有。

更新

net.tcp 默认没有安装在 IIS 上。通过添加/删除功能确保已安装它并检查 TCP 是否打勾。

有 1001 种不同的设置必须正确。您需要有一个运行 4.0 的应用程序池,因此如果您尚未创建单独的应用程序池,请执行此操作并将其设置为 4.0 并让应用程序在其中运行。

转到网站的高级属性,在启用的协议上输入“http, tcp”。

【讨论】:

  • 我也尝试过添加 808 ......仍然不起作用 :(......我可以尝试的任何其他东西吗?
  • 转到站点的高级属性并在启用的协议上输入“http, tcp”
  • 还有什么我可以尝试的吗?
  • 旧但只是一个问题。这不应该是“http,net.tcp”还是简单的“http,net.tcp”仍然可以工作?我之前尝试过后者,但它之前对我不起作用,但是当我尝试它之前,我的 web.config 又出现了错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2010-11-05
  • 1970-01-01
  • 1970-01-01
  • 2011-11-02
  • 2023-03-04
相关资源
最近更新 更多