使用C#Windows Store应用程序通过POST将数据传输到Web服务器

时间:2013-03-10 12:18:12

标签: c# windows-8 windows-runtime httpclient

我正在尝试通过POST将数据从我的Windows应用商店应用程序传输到我的网络服务器。 我尝试了以下方法:

            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(...);
}

0 个答案:

没有答案