title: Ajax-Enabled WCF Service return error 500 when hosted on IIS
body: <p>I'm trying to set up an Ajax-Enabled WCF Service with my Web Application. I can use it just fine with visual studio, however when I publish the website and host it on IIS, the service doesn't seem to be managed properly.</p>
  
  <p>For instance :</p>
  
  <p>When Hosting the web site through Visual Studio (with cassini I assume), I get a Javascript file generated on my localhost <code>localhost:62006/WebServices/SaphirExternService.svc/jsdebug</code> which allows me to call the method of the webservice from the javascript. </p>
  
  <p>However on the production environnement, when I should be getting <code>/WebServices/SaphirExternService.svc/js</code> there is a server 500 error. Actually I cant even browse to <code>url/WebServices/SaphirExternService.svc</code> (same 500). </p>
  
  <p>The error is as follow (translated approximately) :</p>
  
  <pre><code>could not load the type 'System.ServiceModel.Activation.HttpHandler' from the assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
  </code></pre>
  
  <p>MyService.svc contains :</p>
  
  <pre><code>&lt;%@ ServiceHost Language="C#" 
  Debug="true" Service="WebApplication.WebServices.SaphirExternService" 
  Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"
  CodeBehind="SaphirExternService.svc.cs" %&gt;
  </code></pre>
  
  <p>The service is declared as follow in the aspx :</p>
  
  <pre><code>&lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"&gt;
      &lt;Services&gt;
          &lt;asp:ServiceReference Path="~/WebServices/SaphirExternService.svc" /&gt;
      &lt;/Services&gt;
  &lt;/asp:ScriptManager&gt;
  </code></pre>
  
  <p>and called as follow in the javascript :</p>
  
  <pre><code>var service = new WebServices.SaphirExternService();
  service.DoWork("test", DoWorkSuccess, null, null);
  </code></pre>
  
  <p>Finally the Web.config :</p>
  
  <pre><code>&lt;services&gt;
    &lt;service name="WebApplication.WebServices.SaphirExternService"&gt;
      &lt;endpoint address="" behaviorConfiguration="WebApplication.WebServices.SaphirExternServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplication.WebServices.SaphirExternService" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="WebApplication.WebServices.SaphirExternServiceAspNetAjaxBehavior"&gt;
        &lt;enableWebScript /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p>This works fine on visual studio itself however this no longer work when published and hosted on IIS (since the <code>/js</code> file is not generated, SaphirExternService is not defined). I've tried using several endpoint configuration (like the <code>bindingConfiguration</code> attribute) to no avail. What am I missing ?</p>