If you have existed WCF service library and want to host this WCF serivce in your ASP.NET MVC4 application I have prepared this short how-to.

For example you have WCF service located in FooWCF assebly and  MVC4 application located in BarWeb project.

Open BarWeb project and add reference to FooWCF assebly.

Now, add testService.svc WCF Service file in to BarWeb project, remove ItestService.cs and testService.svc.cs files from project.

Open testService.svc and replace

<%@ ServiceHost Language="C#" Debug="true" Service="testForBlock.testService" CodeBehind="testService.svc.cs" %>


<%@ ServiceHost Language="C#" Debug="true" Service="FooWCF.Service1" %>

Then open web.config and add:

      <service behaviorConfiguration="FooWCF.Behavior" name="FooWCF.Service1">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" name="BasicHttpBindingEndpoint" contract="FooWCF.IService">
            <dns value="localhost" />
        <endpoint address="/rest" binding="webHttpBinding" contract="FooWCF.IService" behaviorConfiguration="restBehavior" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="MexHttpBindingEndpoint" contract="IMetadataExchange" />
           <add baseAddress="http://localhost/testService.svc"/>
        <behavior name="FooWCF.Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        <behavior name="restBehavior">
          <webHttp />
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

We have used this behaviour in Advanced Tic Tac Toe because when we start creating web based version of this game we already have WCF service library with all game logic.