标题:[求助]winForm 如何向 webForm 提交数据
只看楼主
amyeeq
Rank: 2
等 级:论坛游民
威 望:1
帖 子:63
专家分:10
注 册:2006-8-22
结帖率:66.67%
 问题点数:0 回复次数:1 
[求助]winForm 如何向 webForm 提交数据
winForm 如何向 webForm 提交数据
搜索更多相关主题的帖子: webForm winForm 数据 
2007-08-07 15:42
sean88
Rank: 1
等 级:新手上路
帖 子:146
专家分:0
注 册:2007-3-27
得分:0 
以下是引用amyeeq在2007-8-7 15:42:17的发言:
winForm 如何向 webForm 提交数据

这样试一下:

方法:
Public Function PostDate()Function PostDate(ByVal url As String, ByVal PostData() As String) As String
Dim Post As String = ""
For Each s As String In PostData
Post += s + "&"
Next
Post = Post.Substring(0, Post.Length - 1)
Dim html As String = ""

Dim encoding As Encoding = encoding.GetEncoding("GB2312")
Dim data As Byte() = encoding.GetBytes(Post)
Dim myRequest As HttpWebRequest = CType(WebRequest.Create(url), HttpWebRequest)
myRequest.Method = "POST"
myRequest.ContentType = "application/x-www-form-urlencoded"


myRequest.ContentLength = data.Length
Dim newStream As Stream = myRequest.GetRequestStream()
newStream.Write(data, 0, data.Length)
newStream.Close()
Dim resp As HttpWebResponse = CType(myRequest.GetResponse(), HttpWebResponse)
Dim sr As StreamReader = New StreamReader(resp.GetResponseStream(), System.Text.Encoding.Default)
html = sr.ReadToEnd()

Return html
End Function

调用:
Dim postdata As String() = {"id=luajiu", "pw=xxxx", "ipmask=0"}
Dim strUrl As String = "http://bbs.cau.edu.cn/wusetu.cn/bbslogin"
Dim SessionHtml As String = PostDate(strUrl, postdata)


Knowledge is infinite.
2007-08-07 17:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-160966-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.386951 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved