I have created a web service. I want to access this web service using Ajax jQuery. I am able to access on same domain. But I want to access this web service from another domain.
Does anyone have an idea how to create a cross domain web service in asp.net? Any setting in web.config
file so that I access it from another domain?
My web service
[WebService(Namespace = "http://tempuri.org/")]
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service () {
}
[WebMethod]
public string SetName(string name) {
return "hello my dear friend " + name;
}
}
JavaScript
$.ajax({
type: "GET",
url:'http://192.168.1.119/Service/SetName.asmx?name=pr',
ContentType: "application/x-www-form-urlencoded",
cache: false,
dataType: "jsonp",
success: onSuccess
});