0
我試圖在「http://www.indianrail.gov.in/cgi_bin/inet_srcdest_cgi_time.cgi」使用asp.net發佈數據的響應與C#。問題是我使用的代碼不能發佈多個數據。此代碼已經正常工作時,我曾在「http://www.indianrail.gov.in/cgi_bin/inet_trnnum_cgi.cgi」然而,當我試圖發佈一個以上的數據,這是不工作剛剛發佈的一個數據。另外每個輸入數據都有一個隱藏字段,所以我該怎麼處理這個隱藏字段。在asp.net發佈一個以上的數據用C#和取回
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "lccp_src_stncode=" + src;
postData += ("&lccp_dstn_stncode=" + des);
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://www.indianrail.gov.in/cgi_bin/inet_srcdest_cgi_time.cgi");
myRequest.Method = "POST";
myRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
// Send the data.
newStream.Write(data, 0, data.Length);
newStream.Close();
HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse();
//Get the stream containing content returned by the server.
newStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(newStream,Encoding.UTF8);
// Read the content.
string responseFromServer = reader.ReadToEnd();
File.WriteAllText(@"C:\Users\Zohaib\Documents\Visual Studio 2010\WebSites\WebSite4\App_Data\data.txt", responseFromServer);
// Clean up the streams.
reader.Close();
newStream.Close();
response.Close();