0

我正在尝试获取一个 HttpRequest 来发布此 URL

https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&USERNAME=yo@yo.com&PASSWORD=什么!什么!

我试过使用

WebClient rar = new WebClient();
rar.OpenReadAsync(new Uri(@"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&USERNAME=yo@yo.com&PASSWORD=What!What!"));

rar.DownloadStringAsync(new Uri(@"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&USERNAME=yo@yo.com&PASSWORD=What!What!"));

这是假设删除我在他们网站上的信息,但它没有采取。我正在关注此文档。 http://getsatisfaction.com/exzact/topics/how_can_we_delete_old_records_not_manually

他们说我所要做的就是将正确的 URL 粘贴到网络浏览器中,然后按 Enter 键,它就可以工作了。我将如何在 c# 中做这个等价物?任何帮助都是极好的!谢谢!

4

5 回答 5

1

使用WebClient.DownloadString而不是 DownloadStringAsync。Async 表示不阻塞当前线程的异步方法。

于 2011-04-07T18:42:19.017 回答
0

在提交之前尝试在 WebClient 中设置 User-Agent 标头以查看是否可以解决问题。

rar.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")

如果缺少 User-Agent 标头,许多 Web 服务器都设置为简单地忽略请求。

随后,您在此处使用 HTTPS,因此您也需要设置您ServicePointManager.ServerCertificateValidationCallback的。

于 2011-04-07T18:43:35.657 回答
0

尝试使用 System.Web 类,例如:

        HttpWebRequest req = null;
        HttpWebResponse resp = null;

        try
        {
            req = (HttpWebRequest)HttpWebRequest.Create(url); // enter your url

            req.Method = "post";

            resp = (HttpWebResponse)req.GetResponse();
        }
        catch (Exception)
        {
            throw;
        }

这是 post 方法的示例,您可以使用任何其他 HTTP 方法,例如。检查文档

于 2011-04-07T18:46:28.927 回答
0

这不是您问题的直接答案,但请查看Hammock for REST

于 2011-04-07T18:49:39.253 回答
0
        string uriString = @"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&USERNAME=yo@yo.com&PASSWORD=What!What!";
        using (WebClient webClient = new WebClient { Encoding = Encoding.UTF8 })
        {
            try
            {
                string content = webClient.DownloadString(uriString);
                //do stuff with the answer you got back from the site
            }
            catch (Exception exception)
            {
                //handle exceptions
            }
        }
于 2011-04-07T19:55:07.047 回答