如何通过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"> </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#发布数据. 参考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"); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |