Tuesday, 26 October 2010

Javascript proxy generator uses full URL in set_path in .NET 4

The javascript proxy generator for WCF services used to send just the path as the argument to set_path in .NET 3.5, such as:

service.set_path("/service.svc");

You can see a line of code similar to this if you go through the proxy javascript code.

In .NET 4, this has changed to the full request absolute url:

service.set_path("http://host/service.svc");

I have noticed this change recently when we had an issue with this in IE8. I was getting "Access Denied" exception when the site is requested via HTTPS and the service method is called on click of a button in the page. After spending some time to debug the JavaScript using IE8s built-in developer tool I found the reason for the error is this particular line of code.

Th work around is if you have control over calling the service through the proxy, call set_path on the proxy with the correct path before making the service call as below.

Service.set_path("/ProxyService.svc");
Service.CallMethod(arg, CallBackResult, CallBackError, context);

Read more >>

Read more >>

No comments:

Post a Comment