views:

1495

answers:

6

We are designing a web application using ASP.NET and AJAX and we want to host our WCF Service Layer on a different website and make JavaScript calls to the Service Layer from our client pages. We understand that the browser will not allow AJAX calls to a different port or domain. What is the best way to architect a solution? We are considering using a proxy layer with services hosted on the same domain as the client which has a web reference to the service layer. Is there a better solution?

+6  A: 

It's generally best to limit the number of domains accessed by your page. A server-side proxy is really a good way to go.

keparo
+1  A: 

i think the best way is to call a local Page which call remote resource and returns result. in this way, you avoid cross domains problems

stefano m
A: 
  • You can do virtual hosting of the service and website under same domain but different folder.
  • define the services in different dlls and create svc files in your websites and point the svc files to the dll which has the services
  • server side proxy.
codemeit
A: 

Your load balancer could send all request to /service to your service server.

If you don't have a load balancer, you can have your webserver act as a reverse proxy to your service server. If you are using IIS7, you can do this with the Application Request Routing module.

Lance Fisher
A: 

Prototype has a plug in for this. The issue is on the client not the server. www.mellowmorning.com/2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/