Hosting WCF Service in IIS


This article demonstrates how to host WCF service in IIS. As we know that we can not consume WCF service directly by our client application, the service must be hosted somewhere to make it consumable. in my previous article I have explained four ways of hosting service. IIS hosting is one of them. Hosting WCF service in IIS is not a difficult process, but need to follow a certain process.

Getting Started

Let's say I have a service called HellowWorldService and I will host this service in IIS to make it consumable by my client. AS I mentioned above hosting a WCF service is very simple and certain steps.


Build your service code, make sure you are building your service code is not in debug mode it must be built in release mode. Because compiling or building code in release mode is more faster than debug mode


Open IIS manager, if you have installed IIS in your computer or you can download IIS and install it your computer. There are various sites are available to get the IIS setup file. you can download the IIS setup file from this site also Click here to download the IIS setup file.

after downloading setup file(IIS Setup file) install IIS manager in your computer, to get help for installation click here

There are two ways to open IIS Manager one is by the control panel and other is window run. To open IIS Manager by windows run write down the following command in the window run window.


To open IIS manager go to control panel, open Administrative Tools. in administrative tool you will find Internet Information Services (IIS) Manager , click on the internet information service manager. you will find Internet Information Service is opened in a new window.


In the Internet Information Service manager window under connections panel which resides in the left side of the above window, you will find sites node. All the service or web sites are hosted under this node in IIS.

Right-click the sites node a small popup window will open and click on the Add Website.. menu.

After clicking Add Website... menu, Add Website window will be opened. enter your service name what you want to give.

On the right side of the Physical path text box a button resides, click on the button to browse a directive to store your compiled service code. Select a directive or folder or you can create also, make sure that the folder or directive name you are going to select or create to store your compiled code is the same as the service name. then click on the Test Setting button after selecting the director to test your settings.

Select protocol type in the drop-down control which resides under the binding group, by default the HTTP protocol is gets selected.

Assign a IP address from IP address drop-down control, if you assign IP address you will able to access service through the assigned IP address, otherwise, IIS will treat your service address as dynamic.

Give a port number to access your service through the port, make sure that you are giving a unique number otherwise IIS manager will through exception.

Host name is optional, if you dont want to access your service through IP address, you can give a name to your service address. for more details about host name click here.

Finally, click on the OK button to finish hosting your WCF service. after finishing hosting you will find your WCF service listed under site node of the connection panel.

Select your service and in the right-side panel click on the browse menu, if you are hosted successfully browser will not give error otherwise you will get the following page like the image below.

Related Articles

  1. WCF Self Hosing
  2. Hosting WCF Service


Above steps successfully hosts the WCF Service in the IISHope you will totally understood how to host WCF service in IIS


No comments:

Post a Comment