2017-03-21 1 views

답변

1

v100을 사용하고 있습니까?

것은 예, 다음과 같은 코드를 시도 할 경우

 ArcGISHttpClientHandler.HttpRequestBegin += (sender, request) => 
     { 
      var cookieContainer = ((System.Net.Http.HttpClientHandler)sender).CookieContainer; 
      var cookies = cookieContainer.GetCookies(request.RequestUri); 
      var customCookie = new Cookie("customCookie", "someValue") { Domain = request.RequestUri.Host }; 
      bool foundCookie = false; 
      foreach (Cookie cookie in cookies) 
      { 
       if (cookie.Name == customCookie.Name) 
       { 
        foundCookie = true; 
        break; 
       } 
      } 
      if (!foundCookie) 
       cookieContainer.Add(customCookie); 

     }; 

ArcGISHttpClientHandler 모든 요청에 ​​호출되는 이벤트 HttpRequestBegin 있습니다. CookieContainer.GetCookies 및 Add를 사용하여 쿠키를 검색/추가 할 수 있습니다.

+0

예, v100을 사용하고 있습니다. –

+0

해답을 가져 주셔서 감사합니다. 이것은 효과가있는 것 같지만 의심 스럽습니다. 응답 객체에 어떻게 추가합니까? –

+0

이 시점에서 나가는 요청에만 헤더를 추가 할 수 있습니다. 아마도 당신이 달성하고자하는 것에 대해 좀 더 자세한 내용을 공유 할 수 있습니까? – dotMorten

관련 문제