0
サーバー上の画像をアップロードしようとしていますが、サファリで正常に動作していますが、クロムでは動作しません。私はこのエラーに直面する。プリフライトのクロムWCFサービスで無効なHTTPステータスコード405があります
のXMLHttpRequestは、プリフライトのための "URL" レスポンスが無効なHTTPステータスコード405
//インタフェース
public interface ISignatureUpload
{
[OperationContract(Name = "AddEPCRSignUpload")]
[WebInvoke(Method = "POST", UriTemplate = "/AddEPCRSignUpload?fileName={fileName}", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
string AddEPCRSignUpload(string fileName, string sigFile);
}
//インターフェイスの実装コード
public class SignatureUpload : ISignatureUpload
{
public string AddEPCRSignUpload(string fileName, string sigFile)
{
// Some Code to upload file
}
}
//のWeb.Configを持ってロードすることはできません
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
<system.web>
</system.web>
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="SignatureService.WebHttp" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
sendTimeout="00:05:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="SignatureUpload.Behavior" name="SignatureUpload.SignatureUpload">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="SignatureService.WebHttp" contract="SignatureUpload.ISignatureUpload">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SignatureUpload.Behavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
// JS
var imageInspector = document.getElementById("sigcanvas").toDataURL("image/png");
imageInspector = imageInspector.replace('data:image/png;base64,', '');
jQuery.support.cors = true;
$.ajax({
url: 'http://serverip/DCASSigUpload/SignatureUpload.svc/AddEPCRSignUpload?fileName=' + itemID + "~Signature~sigcanvas",
type: 'POST',
//data: '{ "sigFile" : "' + image + '" }',
data: JSON.stringify(imageInspector),
crossDomain:true,
dataType: 'json',
//processData: false, // Don't process the files
contentType: 'application/json; charset=utf-8',
//contentType: "application/octet-stream",
success: function (data) {
//$("#modal-content, #modal-background").toggleClass("active");
alert("Done");
},
error: OnGetAllMembersError
});
今完璧な仕事だけ変更方法= "POST"、 "*" は、完璧な仕事します今 –