在IIS7中启用net.tcp

时间:2010-07-06 17:24:16

标签: iis-7 net.tcp

如何使 IIS 处理 net.tcp 连接?

3 个答案:

答案 0 :(得分:118)

您需要将net.tcp添加到您网站的已启用协议中。转到IIS管理器,右键单击您的网站,转到“管理网站”或“管理应用程序”,然后转到“高级设置...”。在那里你看到'启用协议'。它可能会说http。将其更改为http,net.tcp

如果要配置绑定,请右键单击您的网站并转到“编辑绑定...”。默认的net.tcp绑定是808:*

如果要在net.tcp后面使用IIS托管的WCF服务,您可能还需要检查是否已激活所需的Windows功能。转到Windows功能并检查是否已激活“Windows Communication Foundation非HTTP激活”(位于“Microsoft .NET Framework 3.5.1”下)。

激活此功能后,您将获得一些额外的Windows服务。如果它仍然不起作用,请检查名为'Net.Tcp监听器适配器'的Windows服务是否正在运行(应该自动启动但有时不启动,这是我检查的第一个地方我的net.tcp服务停止工作)。

答案 1 :(得分:7)

这有助于将来的某些人。我创建了一个powershell脚本,如果您需要automate the creation of the bindings,它将非常有用。

它会自动检查绑定是否已存在,只在需要时添加。

实际脚本

Import-Module WebAdministration

$websites = Get-ChildItem 'IIS:\Sites'
$site = $websites | Where-object { $_.Name -eq 'Default Web Site' }
$netTcpExists = [bool]($site.bindings.Collection | ? { $_.bindingInformation -eq '808:*' -and $_.protocol -eq 'net.tcp' })

if (!$netTcpExists)
{
    Write-Output "Net TCP binding does not exist. Creating binding now..."
    # Create the binding
    New-ItemProperty 'IIS:\Sites\Default Web Site' -name bindings -Value @{protocol="net.tcp";bindingInformation="808:*"}

    Write-Output "Binding created"
}
else
{
    Write-Output "TCP Binding already exists"
}

Write-Output "Updating enabled protocols..."

Set-ItemProperty 'IIS:\sites\Default Web Site' -name EnabledProtocols -Value "http,net.tcp"

Write-Output "Enabled protocols updated"

答案 2 :(得分:1)

最后一步对我有用。

  1. 确保在网站的“高级设置”中定义了这些协议 enter image description here
  2. 确保已安装以下功能 enter image description here
  3. 以下服务应正在运行 enter image description here
  4. 您的应用程序池应使用集成管道
  5. 关闭IIS管理器,重置IIS,然后再次打开IIS管理器
  6. 检查applicationHost.config文件中的listenerAdapters部分(位于C:\ Windows \ System32 \ inetsrv \ config中)。如果没有看到要在绑定中使用的那些侦听器适配器,请手动添加它们 enter image description here 来源:Missing bindings in IIS (net.tcp, net.pipe, net.msmq, msmq.formatname)