I have developed some projects using WCF and on deployments I face an error thrown by IIS7 saying “The page you are requesting cannot be served because of the extension configuration” with an HTTP Error 404.3 – Not Found. It happens when I hit a URL something like: localhost/coreservice/myservice.svc

IIS7 does not recognize this extension and that needs to be installed from a utility called “ServiceModelReg.exe” found under C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
This utility has many command line switches, the one required to vanish that error “-i” to install this version of WCF and update scriptmaps at IIS metabase root and below that.

How to: Its really simple navigate to the directory ie C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation from command prompt and type: ServiceModelReg -i and press enter. This will install the WCF version and you can now hit the service url without any error.

Tip: If you are disallowed by windows due to lack of privileges to execute ServiceReg, run the command prompt as administrator. You can do so by typing cmd in Win7 search menu under programs and chose run as Administrator

With this post listed here many others and I have the reference how to solve it in future.

Enhanced by Zemanta

The Problem :I faced this issue when hosting my WCF application on my shared hosting, that’s what I got:

” This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
Parameter name: item “

The solution involves two simple steps
1. Creating a Host Factory class in WCF project

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.Activation;
using System.ServiceModel;

namespace <Your namespace>
{
/// <summary>
/// Summary description for CoreServiceHostFactory
/// </summary>
public class CoreServiceHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
// Specify the exact URL of your web service
Uri webServiceAddress = new Uri(“http://yourdomain/yourservice.svc”);

ServiceHost webServiceHost = new ServiceHost(serviceType, webServiceAddress);
return webServiceHost;
}
}
}

2. Adding factory reference in .svc file

<%@ ServiceHost Language=”C#” Debug=”true” Service=”YourNameSpace.YourService”
CodeBehind=”~/App_Code/YourService.cs” Factory=”YourNameSpace.CoreServiceHostFactory” %>


Using the approach above I was able to host my WCF right.

The other easy solution I found:

Add a serviceHostingEnvironment section in <system.serviceModel> somewhat like

<serviceHostingEnvironment aspNetCompatibilityEnabled=”true”>
<baseAddressPrefixFilters>
<add prefix=”http://yourdomain.com/servicename.svc”/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

working 100% now