0
asp.netを使用して「http://www.indianrail.gov.in/cgi_bin/inet_srcdest_cgi_time.cgi」にデータを投稿しようとしていますC#で。問題は、私が使用しているコードが複数のデータを投稿できないことです。このコードは、「http://www.indianrail.gov.in/cgi_bin/inet_trnnum_cgi.cgi」に1つのデータを投稿したときに正しく機能しましたが、複数のデータを投稿しようとしているときには機能しません。また、各入力データに1つの隠しフィールドが付いているので、隠されたフィールドとは何が関係していますか?C#でasp.netに複数のデータを投稿し、応答を返す
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();