Announcement

All important changes of my site and my blog will be announced here.

Computer security

This is my hobby. I spend my freetime for it. I am not professional in this area. But I like it very much.

Everything Else

Which doesn’t belong to other categories will land here. It maybe about my daily life, entertainment, music, game … or something like that

Programming

This is my job. That means everyday I must sit before the monitor. Tip something, be annoyed by bugs,… but I simply like it.

Tutorial

When I found something interesting, I would like to share it to everyone. That is the reason for this category comes.

Home » Programming

WCF – Publish WCF Services in IIS 7 step by step for dummies

Submitted by on Friday, 9 April 201011 Comments | 16,594 views

Today I would like a post about deploying WCF in IIS to help you avoiding nightmare from error given back by IIS 7 during installation. In the end of this post, you can host a wcf service in your localhost and call it like following

1. Install IIS 7 on your computer. Control Panel –> Programs and Features –> Turn Windows features on or off –> Navigate to “Internet Information Services” –> Select these options, then click on.

2. After installing IIS 7, open your browser and browse to localhost you will have this page if installation was successful.

3. Build your own WCF services and be sure that you have a running one by starting it through Visual Studio. The URL of your service before publishing will have format of http://localhost:port

4. Ok, now we have a running IIS and running WCF Services. What we should do is making them work together. In Visual Studio windows, right click on WCF services project and choose Publish (remember to start your Visual Studio as administrator, otherwise publishing will fail). Let all options in next dialog as default and enter “Target Location” as “C:\inetpub\wwwroot\StudentService\”

5. On Start –> Run –> inetmgr to open IIS Manager

6. In IIS Manager, right click on Default Web Site and Add Application. Enter Alias name for the service and point it to the real directory where the service locates. After creating the application, try to browse it on your browser

7. If you are lucky, your application will run like a charm but I believe that you may be meet one of following error or all of them. ^^

7.1 This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault=”Deny”), or set explicitly by a location tag with overrideMode=”Deny” or the legacy allowOverride=”false”.

Note: When you meet this error you must consider where IIS locates your error. For example, in the image above the error relates to handlers tag. I have this error twice when publish WCF Services, one with handlers and one with modules.
Solution:
- Navigate to C:\Windows\System32\inetsrv\config

- Right click on file applicationHost.config and open it with Notepad
- Search and find the tag which IIS has error with it and edit overrideModeDefault = “Allow”. Remember to save file before close it

7.2 The Web server is configured to not list the contents of this directory

Solution:
- In IIS Manager, click on real folder of our service –> click Directory Browsing –> Actions: Open Feature –> Enable

7.3 The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.

Solution:
- Open cmd, navigate to C:\windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ and enter “ServiceModelReg -i”. A successful register looks like following

7.4 Handler svc-Integrated has a bad module “ManagedPipelineHandler” in its module list” error.
Solution:
- Open Control Panel –> Programs and Features –> Turn Windows features on or off –> Activate “Windows Communication Foundation HTTP Activation” and “Windows Communication Foundation Non-HTTP Activation”

7.5 The server encountered an error processing the request. See server logs for more details.

Solution:
- Open web.config file, edit includeExceptionDetailInFaults=”false” in serviceBehaviors

<serviceBehaviors>
    <behavior name="DMLService.StudentServiceBehavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
</serviceBehaviors>

7.6 Failed to generate a user instance of SQL Server due to failure in retrieving the user’s local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed.

Solution:
- In IIS Manager, click on Application Pools –> DefaultAppPool –> Right click and choose “Advanced Settings”

- Change Identity to Local System

Hope you can deploy your WCF Services smoothly with help of this post. If you need a WCF Services to test yourself, you can download here “DML Service

Popularity: 26% [?]

My strongly recommended books to read. Choose one and enjoy yourself.

Related Posts:

  • No Related Posts

11 Comments »

  • Rongchaua's blog » WCF, Silverlight – Access WCF REST services with Silverlight said:

    [...] WCF – Publish WCF Services in IIS 7 step by step for dummies [...]

  • Gary said:

    God bless u! I just got myself rescued after 2 days of frustration.

  • Edgar Torres said:

    This blog it’s great, just miss one thing when you install in a 64 bit plattaform, in the pool configuration you go to advanced settings and set Enable 32-bit Applications to true.

    Only this, for the rest information in it’s really helpfull.

  • Curt said:

    Do you have a solution to 7.3 for .net framework 4.0?

  • Patrick Munar said:

    Hi . . I’m using framework 4.0 . . the WCF REST in this framework has no .svc file . . do you know how to publish it?

    Thanks in advance

  • Paul said:

    THANK YOU SO MUCH!!!!!!!!!

    This post took me strait through all my problems

  • Raj said:

    Can you upload images somewhere else ? Your trial period on image hosting service was expired.

  • Vivek said:

    Thanks a lot..you made my day..

  • Umair said:

    ServiceModelReg -i did it for me! I couldn’t figure out why I couldn’t access my service. Thanks!

  • Ashwin said:

    ServiceModelReg -i worked AWESOMELY… You my friend are a god!!

  • David said:

    Just awesome! Saved me a lot of time! Thanks

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.