[英]passing Parameters(such as form feeds) to Website from WinForm(C#)
I'm on my journey of learning C#.我正在学习 C#。 I was trying to create an app to get exam results by asking the user to enter his roll number.我试图通过要求用户输入他的卷号来创建一个应用程序来获取考试结果。
I know I have to use httpwebrequest
or something sounding similar.我知道我必须使用httpwebrequest
或听起来类似的东西。
Here is the source page snippet of the result.php page这是结果的源页面片段。php 页面
<form action="resultstatus.php" method="post" name="myform" id="myform">
<p align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<span class="style6">Please enter your Application Number or Registration Number </span>
<input type="text" name="regno" size="12" maxlength="10" />
<input type="submit" name="submit" value="Submit" onenter = "submit" onclick="submit" />
How can I pass this roll no to the server, so that I can have an HTML page to work upon?如何将此卷号传递给服务器,以便我可以使用 HTML 页面?
How can this be done for a username, password, etc?如何对用户名、密码等进行此操作?
this is what i hv done till now and it produces no result:这是我到目前为止所做的,但没有产生任何结果:
Byte[] Bytes;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://xvc.com/result.php");
Stream RequestStream;
HttpWebResponse Response;
Bytes = Encoding.UTF8.GetBytes("006453");
request.Method = "POST";
request.ContentLength = Bytes.Length;
request.ContentType = "text/Html"; //Set accordingly
RequestStream = request.GetRequestStream();
RequestStream.Write(Bytes, 0, Bytes.Length);
RequestStream.Close();
Response = ( HttpWebResponse) request.GetResponse();
StreamReader ResponseStream = new StreamReader(Response.GetResponseStream(), Encoding.ASCII);
string Result = ResponseStream.ReadToEnd();字符串结果 = ResponseStream.ReadToEnd(); ResponseStream.Close(); ResponseStream.Close(); MessageBox.Show(Result);消息框.显示(结果);
You basically have to create a HTTP POST to resultstatus.php
and provide it with the roll no ( regno
).您基本上必须创建一个 HTTP POST 到resultstatus.php
并为其提供卷号( regno
)。
You'll probably want to see this almost identical question and in particular this article .您可能希望看到这个几乎相同的问题,尤其是这篇文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.