| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 762 人关注过本帖
标题:[求助]winForm 如何向 webForm 提交数据
只看楼主 加入收藏
amyeeq
Rank: 2
等 级:论坛游民
威 望:1
帖 子:64
专家分: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
快速回复:[求助]winForm 如何向 webForm 提交数据
数据加载中...
 
   



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

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