Click here to Skip to main content
13,001,350 members (62,900 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


6 bookmarked
Posted 22 Jun 2014

WCF Hosting in IIS Simplified

, 22 Jun 2014
Rate this:
Please Sign up or sign in to vote.
WCF Hosting in IIS Simplified

It’s part 3 in the series of WCF Hosting Tutorials and we are going to implement how we can host a WCF Service in IIS (version 5 or 6)? We have already implemented the following in the series:

Microsoft introduced WCF (Windows Communication Foundation) in .NET Framework v 3.0 with lots of exciting features but the most exciting feature among all was, how it’s different from ASMX services or ASP.NET Web Services? or what’ additional things it provides as compared to ASMX services?

Primary difference is that ASMX or ASP.NET web service is designed to send and receive messages using SOAP over HTTP only. While WCF can exchange messages using any format (SOAP is default) over any transport protocol (HTTP, TCP/IP, MSMQ, NamedPipes, etc). Another WCF Tutorial has detailed discussion on WCF Vs ASMX here.

So, if we are hosting a WCF Service in IIS (version 5 or 6), only HTTP option is available as transport protocol. In later versions of IIS (Internet Information Services), we an use any other protocol (TCP/IP, MSMQ, NamedPipes, etc.) as transport protocol.

Practical Guide to WCF RESTful Service

As we already know that in order to host a WCF Service, we need a managed process. In case of IIS (Internet Information Services), it provides the host process and launches the process as the first request reaches server.

Now, let’s first create a WCF service and later host in IIS.

Create a StudentService Class Library

We have already created a StudentService Class Library project while implementing WCF Self Hosting Tutorial. In order to make things consistent here, we will use the same service, so please go through step 1 of that WCF Tutorial for creating a WCF Service.

WCF Hosting in IIS

So in order to host our WCF Service in IIS, follow the simple step by step approach.

  1. Add a Website to our Solution. Choose “ASP.NET Empty Web Site” template. For Web location, choose “HTTP” instead of “File System”, provide the path and press “OK” button.

    WCF Hosting in IIS

  2. Add Reference of StudentService project to our website, i.e. StudentIISHost.

    WCF Service Reference

  3. Add Reference of System.ServiceModel to website.
  4. Add a new .svc file to our website project as:

    WCF Service

    WCF Service Host

    In the above code, we are pointing Service to StudentService in ServiceHost.

  5. Updated configuration for System.ServiceModel in web.config will be as follows:
                    <behavior name="StudentServiceBehavior">
                               <serviceMetadata httpGetEnabled="true"/>
                               <serviceDebug includeExceptionDetailInFaults="false"/>
                    <service behaviorConfiguration="StudentServiceBehavior"
                                <endpoint address="http://localhost/StudentIISHost/MyStudentHost.svc"
                                                   <dns value="localhost"/>
                               <endpoint address="mex"
  6. Access the hosted WCF Service, i.e., StudentService using following path:

    WCF Service Running

Hopefully, this WCF Tutorial will help to understand implementation for hosting a WCF Service in IIS (Internet Information Service).

Other Related Articles

The post WCF Hosting in IIS Simplified appeared first on WCF Tutorial.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Imran Abdul Ghani
Software Developer (Senior) Emaratech
United Arab Emirates United Arab Emirates
Imran Abdul Ghani has more than 10 years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET(MCSD.NET) since 2005. You can reach his blogging at WCF Tutorials, Web Development, SharePoint for Dummies.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 23 Jun 2014
Article Copyright 2014 by Imran Abdul Ghani
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid