[問題] 關於POST該輸入的參數
小弟今天要對一個網頁傳送POST
利用fiddler抓到TEXTVIEW如下
-----------------------------7d719c1f806fa
Content-Disposition: form-data; name="configfile"
/usr/opt/www/pub/CBS/services/NetPhos-2.0/NetPhos.cf
-----------------------------7d719c1f806fa
Content-Disposition: form-data; name="SEQPASTE"
<KLVDTANFDDYMKALGVGFATRQMAGLTKEISFKLDEEFDETTADDRHVKKLILTLTMGNVVSTRTYPTTI
-----------------------------7d719c1f806fa
Content-Disposition: form-data; name="SEQSUB"; filename=""
Content-Type: application/octet-stream
那我程式碼如下
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://www.cbs.dtu.dk/services/NetPhos/");
myHttpWebRequest.Method = "POST";
string postData =
"-----------------------------7d732224806fa\nContent-Disposition: form-data;
name=\"configfile\"\n\n/usr/opt/www/pub/CBS/services/NetPhos-2.0/NetPhos.cf\n-----------------------------7d732224806fa\nContent-Disposition:
form-data;
name=\"SEQPASTE\"\n<KLVDTANFDDYMKALGVGFATRQMAGLTKEISFKLDEEFDETTADDRHVKKLILTLTMGNVVSTRTYPTTI\n-----------------------------7d732224806fa\nContent-Disposition:
form-data; name=\"SEQSUB\"; filename=\"\"\nContent-Type:
application/octet-stream";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] byte1 = encoding.GetBytes(postData);
myHttpWebRequest.ContentType = "multipart/form-data";
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();
其實我不確定的是
POSTDATA裡面到底要裝什麼
要怎麼表達我要傳送的變數名稱跟內容呢
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.70.85.138
推
06/30 21:55, , 1F
06/30 21:55, 1F
→
06/30 21:56, , 2F
06/30 21:56, 2F
推
06/30 23:03, , 3F
06/30 23:03, 3F
→
06/30 23:03, , 4F
06/30 23:03, 4F
→
06/30 23:04, , 5F
06/30 23:04, 5F
推
06/30 23:24, , 6F
06/30 23:24, 6F
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章