协议"net.tcp"不受支持。

3
当我尝试浏览我的service.svc文件时,一直出现这个错误。
  1. 我已经在IIS的默认网站中启用了TCP。
  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,但需要手动激活。 - marc_s
我正在使用IIS7并激活TCP。 - dotnetgeek
1个回答

2

您需要为URI添加TCP端口。HTTP有一个默认端口,但TCP没有。

更新

默认情况下,IIS未安装net.tcp。请确保通过进入添加/删除功能并选中TCP来安装它。

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

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


我已经尝试添加了808,但仍然不起作用:(...还有其他我可以尝试的东西吗? - dotnetgeek
前往网站的高级属性,在启用的协议中输入“http,tcp”。 - Aliostad
还有其他我可以尝试的吗? - dotnetgeek
1
老旧但只是一个问题。这不应该是“http,net.tcp”还是只有纯粹的“http,net.tcp”仍然可以工作?我以前尝试过后者,但它没有为我工作,但再一次,当我尝试时,我的web.config是有故障的。 - Bahamut

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接