Take the 2-minute tour ×

We have built an html web listener (C#) on a local machine to listen for any webservice requests coming from the local browser. The local browser is doing this through javascript XMLHttpRequest on a specific webpage we are building. We control both the local machine and the webpage loaded (but not the server host). We know there are cross domain issues to pay attention to because the webpage is loaded from a non-local domain. We control the webpage permissions so that it is only available for the one user who is logged in on that same machine.

What is the best practice technology of the local webservice and javascript to handle the local webservice call? We need the webservice to both make the connection and pass back specific information from the local machine asynchronously. We would prefer to not add a url to the safe-zone internet security, but rather use known secure technology to pass information from the local machine.

If it is CORS, what do we need to add to the local web listener C# project to allow this type of connection? And also what does the CORS version javascript XMLHttpRequest look like? We hope there no settings change required on the webserver itself (we are not allowed).


share|improve this question
There is a technique of executing JavaScript functions even in a cross-domain environment. If you don't have control on the webserver setting can you at least do some modifications on your webservice methods? I know a solution if so. –  Jobert Enamno Jan 16 '13 at 2:22
We found out that we need to: add in our web listener code: response.Headers.Add("Access-Control-Allow-Origin", "*"); and our javascript can use: postMessage or the iframe proxy (depending on browser support) –  user1843608 Jan 16 '13 at 2:47
add comment

Your Answer



Browse other questions tagged or ask your own question.