Hosting WCF service with netTcpBinding or netNamedPipeBinding in IIS

This article describes you necessary actions to host your WCF services with netTcpBinding or netNamedPipeBindings in IIS. IIS supports http or https protocols by default however to use netTcpBindings or netNamedPipeBinding you need to manage some settings in IIS.

Follow the below steps to create a WCF service with netNamedPipeBindings and host it in IIS.

  1. Create WCF library

    Create a new service using Create new WCF service library and test using WCFTestClient

  2. Host WCF Service in IIS

    Host the WCF Service using hosting WCF service in IIS

  3. Check TCP and Named Pipe Services

    For netTcpBinding and netNamedBinding respective services needs to be already started. Follow the below steps to check whether these services are started.

    1. Open Services window by executing command Services.msc from windows Run.
    2. In the Services window check below services are started and if it is not then start it.
      a. Net.Pipe Listener adapter if you are using netNamedPipeBinding.
      b. Net.Tcp Listener adapter if you are using netTcpBinding.
      c. Net.Tcp Port Sharing services if you using netTcpBinding and sharing the same port with multiple service endpoints.
      start services for netNamedPipe and netTcp
  4. WCF Non-Http Activation from Windows features

    Follow the below steps to activate Non-HTTP protocols.

    1. Open the control panel by executing command Control from windows Run.
    2. Click on Program and Features (if it is not listed on your window click on View by Small icon or large icon).
    3. Click on Windows Features Turn On or Off
    4. From the new window locate Microsoft .Net Framework 3.5.1 and see the sub items of it.
    5. Make sure the check box for Windows Communication Foundation Non-HTTP Activation is selected. Turn Windows features on or off
  5. Enabled Protocols for net.tcp and net.pipe

    Follow the below steps to enable Protocols.

    1. Open IIS Manager by executing command inetmgr from windows Run.
    2. In IIS manager right click on your web site where your services are hosted -> select Manage Web Site -> select Advanced Settings
    3. In Advanced settings set the value for Enabled Protocol as http,net.pipe,net.tcp Enabled protocol for netTcp and netNamedPipe

  6. Edit Binding

    Follow the below steps to enable Protocols.

    1. Open IIS Manager by executing command inetmgr from windows Run.
    2. In IIS manager right click on your web site where your services are hosted -> select Edit bindings
    3. In Edit Bindings window check whether there are binding types available for net.tcp and net.pipe. If not then click on add and add the respective bindings.
      adding binding netNamedPipeBinding to site
      adding binding netTCPBinding to site

With this your services should be ready for consume with WCF services hosted in IIS.

If you are having multiple service endpoints with different bindings and different hosting environment see the article multiple wcf services in one solution with multiple endpoints and hosting.aspx

Source code on Git hub Source Code on Github

Speak your mind
Please login to post your comment!


Blog Search





If you like my content please feel free to buy me coffee. Buy Me A Coffee