.Net Compact Framework 3.5 HTTP POST

时间:2008-11-11 23:45:46

标签: compact-framework http-post

我正在使用.NET Compact Framework v3.5编写我的第一个Windows CE应用程序 我需要该应用程序才能对URL进行HTTP POST 似乎.NET CF没有System.Web 所以,我可以使用.Net CF来使用一些关于如何完成和HTTP帖子的指导。 谢谢, 格雷格

2 个答案:

答案 0 :(得分:1)

这是否满足您的需求?

您需要导入
   System.IO
   System.Net
   System.Net.HttpWebRequest

Try
   Dim Request As HttpWebRequest = CType(WebRequest.Create("<The server>"), HttpWebRequest)

   Request.AllowWriteStreamBuffering = True
   Request.KeepAlive = False
   Request.Credentials = CredentialCache.DefaultCredentials
   Request.ContentType = "text/html"
   Request.Method = "POST"

   'If required
   'Dim proxyURI As New Uri("193.129.241.46", UriKind.Absolute)
   'Dim webProxy As New WebProxy
   'webProxy.Address = proxyURI
   'webProxy.Credentials = New NetworkCredential("", "")
   'Request.Proxy = webProxy

   Dim requestStream As Stream = Request.GetRequestStream
   Dim Writer As New IO.BinaryWriter(requestStream)
   Writer.Close()

   Dim Reader As New BinaryReader(Request.GetResponse.GetResponseStream)
   Reader.Close()
Catch ex As Exception
   Throw ex
End Try

答案 1 :(得分:0)

CF中存在HTTPWebRequest class,可用于发布和抓取响应。快速搜索发现了几篇有关使用它们进行POST的有前途的桌面文章,其中很多都可能被移植。