Click here to Skip to main content
12,943,528 members (53,807 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 14 Dec 2012

Convert WCF Service from Visual Web Developer Express to IIS Express using Web Matrix

, 16 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
An easy guide to run a web service in a more real environment using free tools from Microsoft.


When you have developed a WCF web service using the internal Visual Studio Development Server, you should test it in a more real environment. They say IIS Express is a good choice in this case.

There are several articles/tutorials how to do that using Visual Studio graphical tools and/or full IIS Manager, listed in the additional sources below. This short article is about how to do this if you just have Microsoft Visual Web Developer Express Edition and IIS Express without those graphical tools. The free Microsoft Web Matrix 2.0 will be used for controlling IIS Express instead.

The VWD Express version in question is 2008, but 2010 should be similar. IIS Express version is 7.5. 

Additional sources: 


Using the code

There is a sample Visual Web Developer Express 2008 project attached. It runs the sample generated WCF web service at Microsoft Visual Studio Development Server.

Next, there is its conversion to Web Matrix 2.0 website that runs the same web service using IIS 7.5 Express.

Step 1 – Prerequisites

It’s supposed you have a working WCF service. A way to test it is to run it (see picture 01).

Copy the address from your browser’s address bar (it opens automatically), start a Visual Studio 2008 Command Prompt (it comes with Visual Studio and sets the path for using additional tools) and type:

wcftestclient http://localhost:nnnn/YourService.svc (an address from the browser).

In a graphical tool (see picture 02) you should see a tree of contract(s) containing the web service operation(s). You can doubleclick an operation, set its input parameters (if any) and Invoke it to see if it returns what you expect. 


Step 2 – Install IIS 7.5 Express and Microsoft Web Matrix 2.0 

It can be accomplished in one single step by downloading the installer from

Step 3 – Set the endpoint (optional)

In your VWD Express open your web.config file and modify the binding for your endpoint(s) to basicHttpBinding. This is a suggested step for older target IIS compatibility according to the additional source 3) and might be omitted. If you are not sure, modify the behaviorConfiguration in your web config as follows:

<service behaviorConfiguration="YourService.YourServiceBehavior"

    <endpoint address="basic" binding="basicHttpBinding"

            <dns value="localhost" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

After the change, you can rebuild the VWD Express project and retest the web service functionality (see Step 1).

Step 4 – Convert the project to Web Matrix 2.0 

Don’t use the newly added context menu item  „Open as a Web Site with Microsoft WebMatrix“, which is shown at folders in the Windows Explorer. It would make your following work more complicated.


Instead, start Web Matrix 2.0 directly, click „Templates“, „Empty web“ and set its name as desired.

After the Web Matrix 2.0 GUI has been shown, you can test whether the IIS 7.5 Express works correctly. In a Homepage tab, run the web in your browser and see your system tray if it indicates the IIS start, see picture 04.


Copy the YourService.svc file into the project root.

Replace the Web.config in the root by your modified Web.config from Step 3.

Create the folder App_Code at the same level as App_Data (i.e. in the root). Copy your codebehind file YourService.svc.cs and contract file IYourService.cs to that folder.


Step 5 – Modify the project in the Web Matrix 2.0 

Remove the codebehind reference from YourService.svc markup.

<%@ ServiceHost Language="C#" Debug="true" 

  Service="YourServiceNamespace.YourService" CodeBehind="YourService.svc.cs" %>  

Don’t be confused if Web Matrix underlines the markup in red as incorrect. It works.

If your WVD project was .NET 3.5, you will need to comment out some lines in your web.config because WebMatrix runs the code on .NET 4.0. You will find out, when you restart your modified site and view it in your web browser. If there are corresponding errors listed, modify your web.config as follows.

<sectionGroup name="system.web.extensions"

 System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup,
System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD">

<!--<section name="scriptResourceHandler"
System.Web.Extensions, Version=, Culture=neutral,PublicKeyToken=AAAABBBBCCCCDDDD"
requirePermission="false" allowDefinition="MachineToApplication"/>-->

<sectionGroup name="webServices" type="System.Web.Configuration.
ScriptingWebServicesSectionGroup, System.Web.Extensions,
Version=, Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD">

<!--<section name="jsonSerialization"
type="System.Web.Configuration. ScriptingJsonSerializationSection,
System.Web.Extensions, Version=, Culture=neutral,
PublicKeyToken=AAAABBBBCCCCDDDD" requirePermission="false" allowDefinition="Everywhere"/>-->

<!--<section name="profileService" type="System.Web.Configuration
.ScriptingProfileServiceSection, System.Web.Extensions, Version=,
Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD" requirePermission="false"

<!--<section name="authenticationService"
type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions,
Version=, Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD" requirePermission="false"

<!--<section name="roleService"
type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions,
Version=, Culture=neutral, PublicKeyToken=AAAABBBBCCCCDDDD" requirePermission="false"


After that, your website should show blank page without any error.  

Step 6 – Access your webservice, now running at IIS 7.5 Express

Ensure that Visual Development server is stopped.


You can do that also by closing Visual Web Developer Express. 

Restart your site in WebMatrix 2.0 and run it in your favourite browser. In the address line, there should be <a>http://localhost:nnnn</a>. Append it with /YourService.svc and press Enter.

The web service welcome screen should be shown – the same you can see when it is running under Microsoft Visual Studio Development Server from VWD Express. But now it runs on IIS 7.5 Express. Congratulations.


Step 7 – Retest your webservice hosted at  IIS 7.5 Express

Start WCF test client (see Step 1) and try to invoke web service operations if they work as expected.


When running IIS 7.5 Express I sometimes encounter Internet Connection unavailable error. This can usually be fixed by restarting your website. 


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


About the Author

Adam Wojnar
Software Developer (Senior)
Czech Republic Czech Republic
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralThanks Pin
Member 1049462614-Jan-15 6:02
memberMember 1049462614-Jan-15 6:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170518.1 | Last Updated 16 Dec 2012
Article Copyright 2012 by Adam Wojnar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid