1

在 C# 中使用 POST 数据进行一些编程我遇到了一个小问题。我需要将表单somesite.com连同动态生成的 POST 数据一起发送到某个站点 ( )。起初它是这样完成的:

</form> //closing form from MasterPage
<form action="http://somesite.com" method="POST">
    <input type="text" name="first_name" value="<%=FirstNameValue%>">
    ...
    <input id="SubmitButton" type="submit">
</form>
<form id="form2"> //restoring form from the MasterPage

但这是相当讨厌的黑客攻击。浏览网站上的其他问题,我删除了“somesite”表单并将其作为标准按钮的代码,该按钮曾经是submit

using (WebClient client = new WebClient())
    {
        client.UploadValues("http://somesite.com", new NameValueCollection()
        {
            { "first_name", FirstNameValue }
        }
    });

它肯定会发送一些数据(我希望如此),但我无法对其进行测试,因为它somesite.com包含表单的第二部分 - 更具体地说,它用于向类似于 PayPal 的服务发送请求。

有没有可能让它完全像<form action="http://somesite.com" method="POST">形式一样工作?(点击submit会将您重定向到发送POST数据的网站?)

4

0 回答 0