2017-05-11 10 views
1

私はwcf rest apiを使用してイオンアプリと通信しています。残りのapiを消費している間、コンソールは「405メソッドが許可されていません」というエラーを発生させました。 Googleを検索すると、「CORSエラー」があるはずです。405メソッドが許可されていないWcfサービスとIonic

追加Global.asaxの内部に以下の行は、その後、私はまた、以下のようにweb.configファイル内のエントリを追加することで試してみました

the 'access-control-allow-origin' header contains multiple values 

を得た

protected void Application_BeginRequest(object sender, EventArgs e) 
     { 

      HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); 
      if (HttpContext.Current.Request.HttpMethod == "OPTIONS") 
      { 
       HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache"); 
       HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST"); 
       HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept"); 
       HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000"); 
       HttpContext.Current.Response.End(); 
      } 


     } 

を提出することによって再構成済みのWCFサービス

<httpProtocol> 
     <customHeaders> 
     <add name="Access-Control-Allow-Origin" value="*"/> 
     <add name="Access-Control-Allow-Headers" value="Content-Type, Accept" /> 
     <add name="Access-Control-Allow-Methods" value="GET, POST" /> 
     <add name="Access-Control-Max-Age" value="1728000" /> 
     </customHeaders> 
    </httpProtocol> 

は、今私が見

Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Origin 'http://localhost:8100' is therefore not allowed access. 

どれヘルプ

+0

お読みください - http://stackoverflow.com/a/16039951/4792175 –

答えて

0

私は、私は今、問題を推測します。 [ServiceContract]*をご使用ください。

[WebInvoke(Method = "*" 

このようにして、オプション受信リクエストを許可します。

関連する問題