2016-06-09 4 views
0

나는이 오류를 얻고있다. 프리 플라이트에 대한 응답이이 httpget 호출을 시도 할 때 잘못된 HTTP 상태 코드 405를 가지고 있습니다.응답 유효하지 않은 HTTP 상태 코드 405 AngularJS와

$http({ 
       method: 'GET', 
       dataType: "json", 
       url: 'http://apidev.facu.la/api/json/infotag/search/?criteria=&infotagType=book&companyid=2', 
       headers: { 
        "Content-Type": "application/json" 
       } 
      }).then(function successCallback(response) { 
       alert('ok'); 
      }, function errorCallback(response) { 
       alert('error'); 
       console.log(response); 
      }); 

나는 무엇이 결여되어 있습니까? 우편 배달부 통화는 정상적으로 작동합니다. 감사

UPDATE

:

엔드 포인트 코드 :

[WebInvoke(Method = "GET", 
      RequestFormat = WebMessageFormat.Json, 
      ResponseFormat = WebMessageFormat.Json, 
      BodyStyle = WebMessageBodyStyle.Bare, 
      UriTemplate = "/json/infotag/search/?criteria={criteria}&infotagType={infotagType}&companyid={companyid}")] 
     public XElement InfoTagSearchXML_json(string criteria, string infotagType, int companyid) 
     { 
      return InfoTagSearchXML(criteria, infotagType, companyid); 
     } 
+2

방법은 허용되지 않습니다 (상태 코드 405) 끝점에 OPTIONS 메서드가 정의되어 있지 않다는 의미입니다. CORS 요청에는 필수 항목입니다. [CORS] (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) 참조 끝점에 대한 세부 정보를 제공 할 수 있습니까? (언어, 프레임 워크 등) – KRONWALLED

+0

@Kronwalled가 질문 본문에 전화를 추가했습니다. 나를 도와 준 Thx! – Laziale

답변

0

당신은이 같이 당신의 ServiceContract에 메소드 옵션에 대한 WebInvoke의를 추가 할 수 있습니다

[ServiceContract] 
public interface ITestService 
{ 
    [WebInvoke(Method = "OPTIONS", UriTemplate = "*")] 
    void getOptions(); 

    ... other invokes 
} 

public class Service : ITestService 
{ 
    public void getOptions() 
    { 
     WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Origin", "*"); 
     WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS"); 
     WebOperationContext.Current.OutgoingResponse.Headers.Add("Access-Control-Allow-Headers", "Content-Type"); 
    } 

    ... other invokes 
} 
+0

고마워요 @Kronwalled. 내가 그것을 추가 할 것이고, 그것을 나의 통화에 어떻게 이용할 수 있냐? 아니면 그게 내가해야 할 유일한 것인가? – Laziale

+0

GET 요청을 실행할 때 자동으로 호출해야합니다. – KRONWALLED

+0

변경 후이 오류가 발생합니다. https://i.gyazo.com/83267cb7a48c2a1167c015f83b160079.png – Laziale

관련 문제