POST 経由で Windows ストア アプリケーションから Web サーバーにデータを転送しようとしています。私は次のことを試しました:
try
{
HttpClient httpClient = new HttpClient();
Stream stream = GenerateSampleStream(500);
StreamContent streamContent = new StreamContent(stream);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "address/script.php");
request.Content = streamContent;
request.Headers.TransferEncodingChunked = true; // Assume we do not know the content length
HttpResponseMessage response = await httpClient.SendAsync(request);
}
private static MemoryStream GenerateSampleStream(int size)
{
// Generate sample data.
byte[] subData = new byte[size];
for (int i = 0; i < subData.Length; i++)
{
subData[i] = 64; // '@'
}
return new MemoryStream(subData);
}
私のscript.phpを見ると、POSTデータが得られません:
if($_POST) {
mail(...);
}