C# HttpRequest 发布 URL

发布于 2024-10-30 21:50:16 字数 1445 浏览 2 评论 0 原文

我正在尝试让 HttpRequest 发布此 URL

https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[电子邮件受保护]&PASSWORD=什么!什么

我尝试过使用

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

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

This is Should 删除我在他们网站上的信息,但没有成功。我正在关注这个文档。 http://getsatisfaction.com/exzact/topics/how_can_we_delete_old_records_not_manually

他们说我所要做的就是要做的就是将正确的 URL 粘贴到网络浏览器中,然后按 Enter 键,它就会 工作。我将如何在 C# 中做到这一点?任何帮助都会很棒!谢谢!

I'm trying to get an HttpRequest to post this URL

https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&PASSWORD=What!What!

I've tried using

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

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

This is suppose to delete my information on their site, but it's not taking. i'm following this documentation.
http://getsatisfaction.com/exzact/topics/how_can_we_delete_old_records_not_manually

and they state that all I have to do is paste the proper URL into a web browser and hit enter and it will work. How would I do this equivalent in c#? Any help would be awesome! Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

我乃一代侩神 2024-11-06 21:50:16

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

Use WebClient.DownloadString instead of DownloadStringAsync. Async indicates asynchronous methods that do not block the current thread.

智商已欠费 2024-11-06 21:50:16

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

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

设置了很多Web服务器如果 User-Agent 标头丢失,则最多可以忽略请求。

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

Try setting your User-Agent header in your WebClient before you submit it to see if that fixes things.

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

A lot of web servers are set up to simply ignore requests if the User-Agent header is missing.

Subsequently, you're using HTTPS here so you'll want to set up your ServicePointManager.ServerCertificateValidationCallback as well.

标点 2024-11-06 21:50:16

尝试使用 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 方法。查看文档

Try to use System.Web classes, for example like this:

        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;
        }

It's example for post method, you can use any other HTTP method like this. Check the documentation.

感悟人生的甜 2024-11-06 21:50:16

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

This isn't a direct answer to your question but check out Hammock for REST

§对你不离不弃 2024-11-06 21:50:16
 string uriString = @"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[电子邮件受保护]&PASSWORD=What!What!";
        使用 (WebClient webClient = new WebClient { Encoding = Encoding.UTF8 })
        {
            尝试
            {
                字符串内容 = webClient.DownloadString(uriString);
                //用你从网站返回的答案做一些事情
            }
            catch(异常异常)
            {
                //处理异常
            }
        }
        string uriString = @"https://www.iformbuilder.com/exzact/_emptyTable.php?PAGE_ID=1234&TABLE_NAME=table_name_here&[email protected]&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
            }
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文