以编程方式发布HTML表单? [英] POST a HTML Form programmatically?

查看:79
本文介绍了以编程方式发布HTML表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将HTML表单发布到第三方网站(Mass-SMS短信系统)上.

I need to POST a HTML form to a 3rd party website (a Mass-SMS texting system).

过去,我通过转发到包含我预先填充和隐藏的表单(使用display:none)的页面来完成此操作,然后我在页面末尾运行了javascript函数以自动提交此表格.

In the past I've done this by forwarding to a page containing a form I've pre-populated and hidden (using display:none), then I've ran a javascript function at the end of the page to automatically submit this form.

但是,我希望可以以某种方式通过编程方式完成所有这些操作(因为我不在乎响应,用户不需要查看表单发布到的页面).

However I'm hoping theres someway I can do all this programmatically (as I don't care about the response, and the user doesn't need to see the page the form is being posted to).

我该怎么做?干杯

推荐答案

您可以使用 WebClient.UploadValues 方法,用于从后面的代码向远程服务器发送HTTP POST请求.只需使用来自隐藏字段的值填充名称/值集合即可.

You could use a WebClient.UploadValues method to send an HTTP POST request to a remote server from your code behind. Just fill up the name/value collection with the values coming from the hidden fields.

这篇关于以编程方式发布HTML表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆