大家好,我是 C# 的新手,我正在尝试将一些隐藏字段发布到表单中,我尝试了所有找到的方法,但我似乎无法将参数发送到 aspx 表单,这些是我尝试过的编码的一部分
using (WebClient client = new WebClient())
{
NameValueCollection postData = new NameValueCollection()
{
{ "s_transm", "TEST" },
{ "c_referencia", "TEST" }
};
var result =client.UploadValues(Parameters,"POST",postData);
}
return true;
另一种是通过 HTTPWebRequest
public bool Pay(string Parameters)
{
HttpWebRequest httpWReq =
(HttpWebRequest)WebRequest.Create(Parameters);
var encoding = new ASCIIEncoding();
string postData = string.Format("s_transm=TEST");
byte[] data = encoding.GetBytes(postData);
httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
using (Stream newStream = httpWReq.GetRequestStream())
{
newStream.Write(data,0,data.Length);
}
var r =httpWReq.GetResponse();
return true;
}
唯一可行的方法是直接在表单上点击客户点击帖子,但我想避免这种情况
<input id="Submit1" type="submit" value="submit" />
这些是我一直试图阅读的
protected void Page_Load(object sender, EventArgs e)
{
string s1=Request.QueryString["s_transm"];
string s4 = Request["s_transm"];
string s2 = Request.Form["s_transm"];
string Result = new StreamReader(Request.InputStream).ReadToEnd();
}