[問題] HttpWebRequest 收回網頁的問題

看板C_Sharp (C#)作者 (哞哞)時間18年前 (2007/07/10 14:19), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
小弟要寫一個將一個輸入序列傳至指定網頁之程式 也利用了fiddler把那個網頁的變數找出來了 可是為什麼送出去資料之後 收回的傳回網頁 還是等於沒有送過post的網頁? 我也試過用cookie保持session之類的方法 不知道有沒有大大比較了解httpwebrequest post的用法 看看我是不是哪裡觀念錯誤了 能夠幫忙小弟一下 因為問過很多人也翻過很多書 可是好像都沒有提到類似的東西跟問題 才不得已把程式碼PO在這裡求教 希望大大們能告知一下錯誤 或者指點一下哪裡有參考資料.. 感激不盡 Orz 以下是程式碼: private void button1_Click(object sender, EventArgs e) { CookieContainer cookie = new CookieContainer(); HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://www.cbs.dtu.dk/services/NetPhos/"); myHttpWebRequest.Method = "POST"; myHttpWebRequest.CookieContainer = cookie; string postData = HttpUtility.HtmlEncode("configfile=/usr/opt/www/pub/CBS/services/NetPhos-2.0/NetPhos.cf&" + "SEQPASTE=<KLVDTANFDDYMKALGVGFATRQMAGLTKEISFKLDEEFDETTADDRHVKKLILTLTMGNVVSTRTYPTTI&" + "SEQSUB="); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] byte1 = encoding.GetBytes(postData); myHttpWebRequest.ContentType = " application/octet-stream"; myHttpWebRequest.ContentLength = byte1.Length; Stream newStream = myHttpWebRequest.GetRequestStream(); newStream.Write(byte1, 0, byte1.Length); MessageBox.Show("The value of 'ContentLength' property after sending the data is "+ myHttpWebRequest.ContentLength); newStream.Close(); HttpWebResponse myResp = (HttpWebResponse)myHttpWebRequest.GetResponse(); StreamReader myReader = new StreamReader(myResp.GetResponseStream()); webBrowser1.DocumentText = myReader.ReadToEnd(); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.70.85.138

07/11 10:28, , 1F
已解決
07/11 10:28, 1F
文章代碼(AID): #16aoJa5p (C_Sharp)
文章代碼(AID): #16aoJa5p (C_Sharp)