Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# wp8中post请求的问题_C#_Post_Windows Phone 8 - Fatal编程技术网

C# wp8中post请求的问题

C# wp8中post请求的问题,c#,post,windows-phone-8,C#,Post,Windows Phone 8,我尝试使用这段代码,因为它在控制台应用程序中工作 private static string POST(string Url, string Data) { System.Net.WebRequest req = System.Net.WebRequest.Create(Url); req.Method = "POST"; req.Timeout = 100000; req.ContentType = "applicatio

我尝试使用这段代码,因为它在控制台应用程序中工作

private static string POST(string Url, string Data)
    {
        System.Net.WebRequest req = System.Net.WebRequest.Create(Url);
        req.Method = "POST";
        req.Timeout = 100000;
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] sentData = Encoding.UTF8.GetBytes(Data);
        req.ContentLength = sentData.Length;
        System.IO.Stream sendStream = req.GetRequestStream();
        sendStream.Write(sentData, 0, sentData.Length);
        sendStream.Close();
        System.Net.WebResponse res = req.GetResponse();
        System.IO.Stream ReceiveStream = res.GetResponseStream();
        System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8);
        Char[] read = new Char[256];
        int count = sr.Read(read, 0, 256);
        string Out = String.Empty;
        while (count > 0)
        {
            String str = new String(read, 0, count);
            Out += str;
            count = sr.Read(read, 0, 256);
        }
        return Out;
    }
但当我在wp8应用程序中尝试这段代码时,出现了一些错误:函数GetRequestStream()和GetResponseStream()不存在

你能帮我吗