c# - C# 中的 HTTP 请求

标签 c# asp.net http

我需要访问一个 URL,在所述页面中找到一个特定的文本框 - 用数据填充它,然后提交一个表单。

我如何在 C# 中完成此操作?

附言无辜的意图。

最佳答案

你最好看看 WebRequest类(System.Net)。

您需要查看发布表单的 POST 方法(单击提交按钮并完成必填字段)。

例子:

    // Create a request using a URL that can receive a post. 
    WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx ");
    // Set the Method property of the request to POST.
    request.Method = "POST";
    // Create POST data and convert it to a byte array.
    string postData = "This is a test that posts this string to a Web server.";
    byte[] byteArray = Encoding.UTF8.GetBytes (postData);

MSDN 上有一个很好的教程和大量信息 here . (续上源码)

关于c# - C# 中的 HTTP 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2101628/

相关文章:

c# - 循环变量上的闭包的正确语义是什么?

c# - ASP.NET 5 Identity 3 用户在应用程序重启后注销

c# - 实现自定义 MembershipUser 和自定义 MembershipProvider

javascript - 当调用来自 iFrame 时,如何获取主机站点的 Http_Referrer?

c# - 提高 C# 中的速度性能

c# - 执行 RichTextBox 事件处理程序 "textChanged"

c# - 如何将 Dictionary<string, string> 变量从代码后面传递给 asp.net?

django - 我日志中的这些 CONNECT 消息是什么?

java - HttpPost - http请求方法的类型

c# - C# 是 C 的超集吗?