ASPX接收WINDOWS應用程式以POST方式發來的資訊並存成檔案

來源:互聯網
上載者:User
window|程式

我這個笨蛋終於調出來了。。。不要問我調出了啥,都寫在標題上了。。。。
趕緊寫下來,然後睡覺。。。。

目前已經嘗試了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小,還希望高人指導!



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.