C# 코드가 요청을 다른 URL로 리디렉션해야하는 내 API 서비스 (PHP)를 호출하고 반환하기 전에 응답을 처리합니다. proxy.php
에서내용이있는 다른 URL로 리디렉션
HttpWebRequest request = null;
WebResponse response = null;
Stream writer = null;
request = (HttpWebRequest)WebRequest.Create(http://www.somewhere.com/proxy.php);
request.Method = "POST";
request.ContentType = "multipart/form-data; boundary=" + this.builder.Boundry;
this.builder.RequestStream.Position = 0;
byte[] tempBuffer = new byte[this.builder.RequestStream.Length];
this.builder.RequestStream.Read(tempBuffer, 0, tempBuffer.Length);
writer = await request.GetRequestStreamAsync().ConfigureAwait(false);
writer.Write(tempBuffer, 0, tempBuffer.Length);
writer = null;
response = await request.GetResponseAsync().ConfigureAwait(false);
그리고 :
<?php
// 1. Redirect everything (with the content stream from the C# code) to http://www.elsewhere.com
// 2. Process the response from http://www.elsewhere.com
// 3. Return processed data to my C# code
?>
나는이 어떻게 할 수있는
여기 내 C# 코드는?<?php
header("Location: http://www.somesite.com/another_page.php");
exit();
?>
상관없이 발신자 프로그램은 C# 또는 다른 하나는 : 다른 페이지로 리디렉션 당신은 PHP에 위치 헤더를 사용할 수 있습니다
writer = await request.GetRequestStreamAsync().ConfigureAwait(false);
writer.Write(tempBuffer, 0, tempBuffer.Length);
http://php.net/manual/en/function.header.php – mkaatman
왜 처음부터 elsewhere.com에 전화하지 않으시겠습니까? –
'proxy.php'는 elsewhere.com의 응답을 받아서 C# 코드로 반환하기 전에 변경해야하기 때문에. – Darius