How to host WCF Service in IIS

Kailash Chandra Behera | Thursday, April 07, 2016

Introduction

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

Lets 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 in the above hosting a WCF service is very simple and certain steps.

Step-1

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

Step-2

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 these site also Clieck here to download 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 the other is window run. To open IIS Manager by windows run write down the following command in the window run window.

 inetmgr  

To open IIS manager go to control pannel, 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 new window.

Setp-3

In Internet Information Service manager window under connections panel which resides in the left site of 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.

In the right side of Physical path text box a button is 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 same as service name. than click on the Test Setting button after selecting director to test you 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, other wise IIS will threat your service address as dynamic.

Give a port number to access your service through the port, make sure that your giving 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 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 following page as image below.

Related Articles

  1. WCF Self Hosing
  2. Hosting WCF Service in IIS
  3. Hosting WCF Service

Summary

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

Thanks