2013-05-24 2 views
1

하이 차트 내보내기 서버에 에 HttpRequest를 제출하고 응답에서 407 프록시 인증 요구 오류가 발생했습니다. 하이 차트에 인증을 통과 할 필요가 없었습니다. 이 문제가 발생하는 사람은 누구입니까?Highcharts 내보내기 서버의 POST 매개 변수 407 프록시 인증 오류

// Create a request using a URL that can receive a post. 
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://export.highcharts.com/"); 
      // Set the Method property of the request to POST. 
      request.Method = "POST"; 

      // Create POST data and convert it to a byte array. 
      string options2 = "{xAxis:{categories:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']},series:[{data:[29.9,71.5,106.4,129.2,144.0,176.0,135.6,148.5,216.4,194.1,95.6,54.4]}]}"; 
      string postData = string.Format("const={0}&type={1}&width={2}&options={3}&content=options", "chart", "image/png", 1270, options2); 
      //string postData = string.Format("filename={0}&type={1}&width={2}&svg={3}", "chart", "image/png", 1270, "TEST"); 

      byte[] byteArray = Encoding.UTF8.GetBytes(postData); 

      // Set the ContentType property of the WebRequest. 
      request.ContentType = "application/x-www-form-urlencoded; multipart/form-data"; 

      // Set the ContentLength property of the WebRequest. 
      request.ContentLength = byteArray.Length; 
      // Get the request stream. 
      Stream dataStream = request.GetRequestStream(); 
      // Write the data to the request stream. 
      dataStream.Write(byteArray, 0, byteArray.Length); 
      // Close the Stream object. 
      dataStream.Close(); 
      // Get the response. 
      WebResponse response = request.GetResponse(); 

      HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse(); 
      //This is here just to read the response. 
      string msg; 
      using (StreamReader sReader = new StreamReader(webResponse.GetResponseStream())) 
      { 
       msg = sReader.ReadToEnd(); 
      } 

답변

0

내 HttpRequest에 프록시 설정을 추가해야했습니다. 다음 코드 줄을 추가 한 후, 내 응답은 하이 차트 이미지를 반환하고있었습니다.

request.Proxy = WebRequest.DefaultWebProxy; 
request.Credentials = System.Net.CredentialCache.DefaultCredentials; 
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; 
관련 문제