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.
.. 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.
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 -
- Open IIS Manager, and go to your Port 80 classic mode site that you're trying to fix.
- Go to "Handler Mappings"
- Add a script map for
- Request Path: *.svc
- Executable: %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
- Name: svc-ISAPI-2.0
Run your AJAX app, it should work now. :-)