2016-11-04 2 views
0

확인을 진행하기 전에 CORS 상황이 발생합니다.

서버 # 1 (http://localhost:33233)은 내 서비스 (SOAP, WebAPI)가 호스팅되는 주요 웹 사이트입니다. 또한

protected void Application_BeginRequest(object sender, EventArgs e) 
{ 
    HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin" , "*"); 
    if (HttpContext.Current.Request.HttpMethod == "OPTIONS") 
    { 
     // These headers are handling the "pre-flight" OPTIONS call sent by the browser. 
     HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST"); 
     HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Accepts, Content-Type, Origin");    
     HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000"); 
     HttpContext.Current.Response.End(); 
    } 
} 

, 해당 서버, 내가 요청을받을 때, 나는 헤더에서 세션 토큰하고 있어요에 :

HttpContext.Current.Response.Headers.Set("X-SessionToken", "{...}"); 
을 나는 CORS 요청을 지원하기 위해 Global.asax에 이러한 줄을 추가했습니다

서버 # 2 (http://localhost:41350/login)는 AngularJS로 구축되었으며 원격 서비스를 호출하는 내 모바일 웹 사이트입니다.

로그인 과정에서 나는 SingIn 서비스 (SOAP)를 호출합니다. 나는 중단 점 서버 측을 명중하고, 나는 머리말을 놓고 응답을 돌려 보낸다; 왕복이 효과적입니다.

그러나 응답 클라이언트 쪽에서 헤더를 확인할 때 null 값이 나타납니다.

$http({ 
    method: 'POST', 
    url: 'http://localhost:33233/ws/Authentication.asmx/SignIn', 
    data: {...} 
}).success(function(data, status, header, config) { 
    var mySession = header('X-TokenSession'); 
}).error(function(data, status, header, config){ 
    ... 
}); 

나는 Fiddler 또는 Chrome DevTools에 확인 했으므로 네트워크 트래픽의 헤더 값을 볼 수 있습니다.

문제는 $ httpProvider입니까?

답변

0

마지막으로 대답을 찾았습니다. 세션 토큰을 반환 할 때 "노출"해야합니다.

HttpContext.Current.Response.AddHeader("Access-Control-Expose-Headers", "X-TokenSession"); 
관련 문제