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.
For instance :
When Hosting the web site through Visual Studio (with cassini I assume), I get a Javascript file generated on my localhost localhost:62006/WebServices/SaphirExternService.svc/jsdebug
which allows me to call the method of the webservice from the javascript.
However on the production environnement, when I should be getting /WebServices/SaphirExternService.svc/js
there is a server 500 error. Actually I cant even browse to url/WebServices/SaphirExternService.svc
(same 500).
The error is as follow (translated approximately) :
could not load the type 'System.ServiceModel.Activation.HttpHandler' from the assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
MyService.svc contains :
<%@ ServiceHost Language="C#" Debug="true" Service="WebApplication.WebServices.SaphirExternService" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" CodeBehind="SaphirExternService.svc.cs" %>
The service is declared as follow in the aspx :
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"> <Services> <asp:ServiceReference Path="~/WebServices/SaphirExternService.svc" /> </Services> </asp:ScriptManager>
and called as follow in the javascript :
var service = new WebServices.SaphirExternService(); service.DoWork("test", DoWorkSuccess, null, null);
Finally the Web.config :
<services> <service name="WebApplication.WebServices.SaphirExternService"> <endpoint address="" behaviorConfiguration="WebApplication.WebServices.SaphirExternServiceAspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplication.WebServices.SaphirExternService" /> </service> </services> <behaviors> <endpointBehaviors> <behavior name="WebApplication.WebServices.SaphirExternServiceAspNetAjaxBehavior"> <enableWebScript /> </behavior> </endpointBehaviors> </behaviors>
This works fine on visual studio itself however this no longer work when published and hosted on IIS (since the /js
file is not generated, SaphirExternService is not defined). I've tried using several endpoint configuration (like the bindingConfiguration
attribute) to no avail. What am I missing ?
1 Answers
Answers 1
Found the solution to my issue in case someone needs it for future reference. The svc file were not mapped properly in IIS. I removed all *.svc
related configuration in the Handler Mappings. Then in two steps :
- Added a new Mime Type :
- Extension: .svc
- MIME type: application/octet-stream
- In Handler Mapping > Added a new managed code Handler:
- Request path: *.svc
- Type: System.ServiceModel.Activation.HttpHandler
- Name: svc-Integrated
0 comments:
Post a Comment