Access-Control-Allow-Origin konnte nicht zu meinem WCF-Bibliotheksprojekt hinzugefügt werden
Ich versuche zu verstehen, warum dieser Ajax namens nicht funktioniert
$.ajax({
type: 'GET',
url: "http://localhost:8732/Design_Time_Addresses/InMotionGIT_NT.Address.Service/AddressService/json/capitalize",
data: { streetAddress : JSON.stringify(streetAddress) , consumer : JSON.stringify(consumer)} ,
datatype: "jsonp",
success: function (data) {
$('body').append('<div>'+data.IDblah+' '+ data.prueba+'</div>');
alert(data.IDblah);
}
Der Dienst, der die Daten empfängt, wird korrekt empfangen und die Antwort ist korrekt. Warum mache ich falsch?
Ich habe versucht, diese Eigenschaft zum Ajax hinzuzufügen, aber ohne ErfolgcrossDomain : true
[OperationContract()]
[WebInvoke(Method="GET", RequestFormat=WebMessageFormat.Json, ResponseFormat=WebMessageFormat.Json)]
public string Capitalize(StreetAddress streetAddress,ConsumerInformation consumer)
Der Fehler, den ich bekomme, ist der häufigste
XMLHttpRequest cannot load Origin http://localhost:50816 is not allowed by Access-Control-Allow-Origin.
AKTUALISIEREN
Ich habe versucht, den Header in die Antwort einzufügen, indem ich die Konfiguration in my hinzufügteApp.config
Datei aber ohne Erfolg
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>