加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

如何通过win表单将数据发布到网站c#

发布时间:2020-12-14 18:56:39 所属栏目:资源 来源:网络整理
导读:我有一个api在哪里我可以发布一些数据n提交,然后得到发布的数据是有效还是没有.这个api重定向到不同的URL表示成功/失败. 对于我通常做的是,在html标签内调用目标网址并提交页面: form method="post" action="https://web.tie.org/verify.php" name="main"ta
我有一个api在哪里我可以发布一些数据n提交,然后得到发布的数据是有效还是没有.这个api重定向到不同的URL表示成功/失败.
对于我通常做的是,在html标签内调用目标网址并提交页面:
<form method="post" action="https://web.tie.org/verify.php" name="main">
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" valign="top">
    <tr>
        <td class="normal">&nbsp;</td><td class="normal"><input type='text' class='text' name='Email' value='x@hotmail.com' size='15' maxlength='35'></td>
    </tr>
</table>
</form>
<script language='javascript'>

document.forms[0].submit();

</script>

有没有办法直接通过winforms c#发布数据.
我希望能够在发布后访问成功/失败URL并获取重定向站点的查询字符串.

参考enter link description here我试过发布但我需要结果查询字符串.

现在我可以通过以下方式实现:

webBrowser1.Url = new Uri("C:Documents and SettingsAdminDesktopcalltie.html");            
webBrowser1.Show();

解决方法

是的,您可以使用WebClient类.
public static string PostMessageToURL(string url,string parameters)
{
    using (WebClient wc = new WebClient())
    {
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        string HtmlResult = wc.UploadString(url,"POST",parameters);
        return HtmlResult;
    }
}

例:

PostMessageToURL("http://tempurl.org","query=param1&query2=param2");

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读