WCF serving AJAX troubleshooting

I hope in the RTM you’ll get more help solving your WCF Ajax problems then I currently get, because I’m getting mad from time to time. In my quest for getting things to work, I learned some stuff I wanted to share. Read: have a checklist for myself because I tend to forget this kind of stuff! 😉

  1. First, have a look at the errors your service reports. Right-click your service’s .svc file in Visual Studio 2008 and choose “View in browser”.
  2. If you’re using the WebScriptServiceHostFactory in your .svc file you don’t need anything in your web.config and you can remove the entire part. This is how the .svc then should look like:

<%@ ServiceHost Language=”C#” Debug=”true” Service=”WebApplication1.WCFAjaxService” CodeBehind=”Service.svc.cs” Factory=”System.ServiceModel.Activation.WebScriptServiceHostFactory”%>

  1. The default namespace of your service is http://tempuri.org. You need this in your javascript creating your proxy.

var proxy = new tempuri.org.IWCFAjaxService();

When Internet Explorer tells you the object tempuri isn’t know, you can take a look at the generated javascript to see what the correct objectname is. By placing /js behind your service you can download the javascript.

Example : http://localhost/service.svc/js

  1. The service can’t handle multiple authentication schemes; meaning you can only have anonymous access or integrated security or another option. In IIS Management right-click your website (or virtual directory) and select the “Directory Security” tab, press the first “Edit” button for Authentication and access control and select only one checkbox.
    After this you’ll have to stop and start the website which can be done by using IISRESET in the command prompt.

When I come across more I will post them here, including an update comment.