如何在VPS上托管双工wcf服务

时间:2012-10-16 12:36:08

标签: asp.net wcf vps

我正在尝试托管一个具有以下属性的wcf服务;

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]

我正在创建这样的主机类;

    var uri = new Uri("net.tcp://localhost:7951");
    var binding = new NetTcpBinding();
    host = new ServiceHost(typeof(ChatService), uri);
    ServiceMetadataBehavior smb = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
    if (smb == null) host.Description.Behaviors.Add(new ServiceMetadataBehavior());
    host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
    host.AddServiceEndpoint(typeof(IChat), new NetTcpBinding(), "");
    host.Open();

因此,在开发人员计算机和专用服务器上,这是有效的。但是,我需要做的是,在VPS(虚拟专用服务器)上托管它。

我想创建一个Web项目并将此代码块添加到global.asax应用程序启动方法中。但这失败了。我怀疑端口是否可以从防火墙关闭。

我应该采用什么解决方案?

0 个答案:

没有答案
相关问题