Thursday, February 11, 2010

Fixing Ajax using WCF in Web.config and IIS 7.0

Sometimes when you call WCF from javascript (http://Site/Service.svc/js) or adding your WCF URL as service reference in the script manager, you find that the JS Proxy of the WCF returns 404 not found from the server. You can Check my previous post for more error details here: http://kholyos.blogspot.com/2010/02/how-to-solve-404-not-found-when-calling.html
You can fix this issue using alternative method, by modifying in the web.config of your application. Using the <handlers> tag under <system.webserver> can do the trick for you.

By adding the following Elements under <configuration><system.webserver><handlers> you can fix the issue:

<add name="svc-ISAPI-2.0" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />



<add name="svc-ISAPI-2.0-64" path="*.svc" verb="*" scriptProcessor="%SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" requireAccess="Script" resourceType="Unspecified" />



for more Information about handlers tag, you can follow this link to MSDN: http://msdn.microsoft.com/en-us/library/ms691481.aspx

That's it. And Enjoy :).

1 comment: