我想使用MSDN代码通过HttpWebRequest发布数据,但getresponse()无法正常工作。
System.net.httpwebrequest does not contain a definition for getrequeststream
http://msdn.microsoft.com/zh-CN/library/system.net.httpwebrequest.getresponse.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("http://d.co/login.php");
myReq.Method = "POST";
myReq.ContentType = "application/json";
Stream dataStream = (HttpWebResponse)myReq.GetRequestStream();
Windows Phone上不存在该方法,因为您经常要使用异步IO。您需要GetRequestStreamAsync
或BeginGetRequestStream
。*Async
与相比Begin*
,该方法通常更易于理解和使用,但需要使用最新的编译器。相关示例在电话中提供了一个基于文档的文档:http : //msdn.microsoft.com/zh-cn/library/windowsphone/develop/System.Net.HttpWebRequest(v=vs.105).aspx
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句