Windows 2008, jsDebug gives you Http 404 errors?

Posted on 11/9/2008 @ 11:30 PM in #WCF by | Feedback | 6048 views

Please chalk this one up as responsible for atleast 10 additional white hairs on my head.

Let me describe the symptoms.

You are trying to write an AJAX app, with a WCF backend. So what do you do?

a) You create a WCF Service, and decorate it with the following attributes:

   1: [ServiceContract(Namespace = "winsmarts")]
   2: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

 

b) You then use webHttpBinding, and the <enableWebScript/> endPoint behavior.

c) You add a script reference to the .svc.

d) You write the necessary, much simplified javascript.

.. and it should all work, right? Well yeah .. but .. sometimes it doesn't! Especially if you're running SharePoint - because WSS IIS 7 sites like to run under classic mode.

So, I visited my service reference through the browser at http://smw2k8/_vti_bin/_wcf/SongTypeField/AjaxToolkitMusic.svc, and the service seems to have rendered fine. So, WCF support on SharePoint was working. Then I visited http://smw2k8/_vti_bin/_wcf/SongTypeField/AjaxToolkitMusic.svc/jsDebug, to get the JavaScript proxy, and that sucker gives me a HTTP 404.

WHAT THE HECK!?

Well, here's what is going on.

The SharePoint site is running in classic mode. So even though you followed all the necessary steps here, IIS does recognize .svc, but it gets confused when it finds a wildcard mapping for /jsDebug. Well, there is no such file. Basically it doesn't know what to do with /jsDebug, and it thinks that I was asking for a file called /jsDebug, so it just bombs with an HTTP 404.

Enough chat, How to fix it -

  1. Open IIS Manager, and go to your Port 80 classic mode site that you're trying to fix.
  2. Go to "Handler Mappings"
  3. Add a script map for
    1. Request Path: *.svc
    2. Executable: %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
    3. Name: svc-ISAPI-2.0

IIS reset.

Try visiting the /jsDebug link again - you should be prompted to download the javascript proxy.

Run your AJAX app, it should work now. :-)

Sound off but keep it civil:

Older comments..


On 2/13/2009 5:47:27 AM Lars Berg said ..
Finally after 6 hours I solved my 404 problem and this post lead me on the way.

I'm running Windows 2008 Server 64-bit edition and here the mapping must be to pointed to %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll.

Look at the mappings on the default website to compare the mappings with your Sharepoint site.