WCF javascript provider not found if endpoint address is not empty

I am trying to configure a WCF service with multiple endpoints from one of the endpoints using the enableWebScript endpoint behavior so that a Javascript proxy (jsdebug / js) is created on the client.

When adding the Service Reference to my AJAX ScriptManager, the jsdebug file will not be found if the endpoint address is not empty. ScriptManager proxy always generates the path "MyService.svc / jsdebug" to search for a file, even if my service has an "ajax" address. The proxy should generate a path like "MyService.svc / ajax / jsdebug".

Is there a parameter to get the proxy generated with the correct path? My service is at the core of my website.

work:

<endpoint address="" behaviorConfiguration="ajaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyTest.Web.ICustomerService" /> 

want (doesn't work):

 <endpoint address="ajax" behaviorConfiguration="ajaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyTest.Web.ICustomerService" /> 
+6
wcf javascript-debugger
source share
2 answers

<enableWebScript /> , also known as AJAX-enabled endpoints, essentially hardcodes everything you need to do with the address so that you can generate client-side code.

The way it is hardcoded is that everything is directly related to the .svc file.

See Practical Guide. Using configuration to add an AJAX ASP.NET endpoint

The endpoint is configured to an empty address relative to the .svc file, so the service is now available and can be called by sending requests to service.svc/<operation> - for example, service.svc/Add for the Add operation.

For this reason, you cannot mix <enableWebScript /> with UriTemplate , which, in my opinion, takes away half the fun of WCF. See enableWebScript, UriTemplate, and HTTP methods .

Personally, I like to configure my URI and serve both POX, JSON, and SOAP. See WCF RESTful POX, JSON, and SOAP Coexist .

+2
source share

In ScriptManager, put MyService.svc / ajax instead of MyService.svc

+1
source share

All Articles