All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
ASPX接收WINDOWS应用程序以POST方式发来的信息并存成文件_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/6 9:05:18 Browse times: 383 Comment times: 0

ASPX接收WINDOWS应用程序以POST方式发来的信息并存成文件_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

ASPX接收WINDOWS应用程序以POST方式发来的信息并存成文件_[Asp.Net教程]

我这个笨蛋终于调出来了。。。不要问我调出了啥,都写在标题上了。。。。
赶紧写下来,然后睡觉。。。。

目前已经尝试了ASP,JS,C++,C#,前三个都有数月甚至数年的经验了,争取把最后一个也搞大。。。。

接下来搞啥?

切入正题。。。

Windows端应用程序

1,首先建立两个POST变量,这两个POST变量模拟ASP中的Form的name~~~(我瞎试的,果然是模拟form)


System.Net.WebClient WebClientObj=new System.Net.WebClient();
System.Collections.Specialized.NameValueCollection PostVars=new System.Collections.Specialized.NameValueCollection();
PostVars.Add("c",textBox2.Text);
PostVars.Add("b",textBox3.Text);
//textBox2.Text里面存的是要POST的信息哈

2,然后传送给一个网页:http://www.dc9.cn/t/default.aspx

try
{
byte[] byRemoteInfo=WebClientObj.UploadValues("http://www.dc9.cn/t/default.aspx","POST",PostVars);
//下面都没用啦,就上面一句话就可以了
string sRemoteInfo=System.Text.Encoding.Default.GetString(byRemoteInfo);
//这是获取返回信息
textBox1.Text=sRemoteInfo;
axDHTMLEdit1.DocumentHTML=sRemoteInfo;
//下面用了COM组件WebBrowser,让他显示返回信息,没什么用,可以不看。
object url="about:blank";
object nothing=System.Reflection.Missing.Value;
this.axWebBrowser1.Navigate2(ref url,ref nothing,ref nothing,ref nothing,ref nothing);
((mshtml.IHTMLDocument2)this.axWebBrowser1.Document).write(sRemoteInfo);
}
catch
{}


WEB端应用程序

1,在Page_Load里写

string MyText=System.Web.HttpContext.Current.Request.Form["c"];
string MyText2=System.Web.HttpContext.Current.Request.Form["b"];
//获取两个POST来的信息
StreamWriter sw=new StreamWriter(Server.MapPath(".")+"\\1.shtml", true, Encoding.UTF8);
sw.Write(MyText);
sw.Write(MyText2);
sw.Close();
//true的意思就是以append的方式写入POST来的信息


恩,就写到这里。

不知道用这种方法写文件是不是比FSO和AdodB.stream效率高占用cpu小,还希望高人指导!

来源:网络





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.