[英]The protocol 'net.tcp' is not supported
当我尝试浏览我的service.svc文件时,我不断收到此错误。
但是,现在为什么我无法浏览网站? 它一直显示“不支持协议'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;
}
}
}
请帮我...
非常感谢
您需要为您的uri添加TCP端口。 HTTP有一个默认端口,但TCP没有。
UPDATE
默认情况下,IIS上未安装net.tcp。 通过添加/删除功能确保安装它并检查TCP是否已勾选。
有1001个不同的设置必须是正确的。 您需要有一个运行4.0的应用程序池,因此如果您尚未创建单独的应用程序池,请执行此操作并将其设置为4.0并让应用程序在其中运行。
转到站点的高级属性,在启用的协议上输入“http,tcp”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.