如何在 WP7 中使用 HttpWebRequest 发布表单数据?
我见过很多使用 HttpWebRequest 发布表单数据的示例,但不幸的是,我很难找到一篇在 WP7 中处理此类的具体文章。有人对如何做到这一点有很好的参考吗?
请注意,我不想上传文件,我只需要发出“POST”命令发送一些键/值对(例如)。我无法使用“GET”发送数据。
i've seen a lot of examples of using HttpWebRequest to post form data, but unfortunately, i'm having a hard time finding a specific article dealing with this class in WP7. does anyone have a good reference on how to do this?
note, i don't want to upload a file, i just need to issue a "POST" command sending some key/value pairs (e.g. ) . i can't use "GET" to send the data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://msdn。 microsoft.com/en-us/library/system.net.webclient.uploadstringasync(v=vs.95).aspx
http://msdn.microsoft.com/en-us/library/system.net.webclient.uploadstringasync(v=vs.95).aspx
将
HttpWebRequest.Method
设置为POST
后,调用BeginGetRequestStream
。完成后,EndGetRequestStream
将返回您可以写入的Stream
。如果您使用 Mango,
WebClient
可能会更容易。 (WebClient
在 Mango 之前就已存在,但建议不要使用,因为它总是在 UI 线程上返回)After settings
HttpWebRequest.Method
toPOST
, callBeginGetRequestStream
. When it completes,EndGetRequestStream
will return theStream
that you can write to.If you're using Mango,
WebClient
is probably going to be easier. (WebClient
existed pre-Mango, but was recommended against as it always returned on the UI thread)