Click here to Skip to main content
15,035,723 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a Windows Service which self hosts a WCF service. The Windows Service contains all of the logic. The WCF Service call using ajax but browsers sending error like Method Not allowed and No Access-Control-Allow-Origin. using this
<pre>WebServiceHost host = new WebServiceHost(typeof(Generat), new Uri("http://localhost:8800/GetClient"));
            ServiceMetadataBehavior smb = new Ser<code></code>viceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            host.Description.Behaviors.Add(smb);
            host.Open();


What I have tried:

self host wcf service successfully and windows service also start properly but when call from another web application give error
and call using ajax


$.ajax({
                url: 'http://localhost:8800/BCon/GetClient',
                type: 'GET',
                contentType: 'application/json;charset-uf8',
                dataType: "json",
            }).success(function (data) {
               alert(data);
            }).error(function (error) {
                alert(error);
            });
Posted
Updated 22-Nov-17 20:52pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900