c# windows 表单 - 如何在点击按钮后在网站上添加条目

c# windows form - How to make add entry on website after click button

你好,我正在为我的训练编程制作一个小应用程序。我是 1 天学习者 :D.

我想在我的论坛中创建生成器 post。我创建了简单的生成器,现在我想从应用程序将 post 制作成网站。

http://localhost/web/newthread.php?fid=5 <-- Its link to post website

<input type="text" class="textbox" name="subject" size="40" maxlength="85" value="" tabindex="1"> Its  place for Title on website

<body contenteditable="true" dir="ltr" class=" placeholder"><p><br></p></body> <-- Its place for entry

<input type="submit" class="button" name="submit" value="Napisz wątek" tabindex="4" accesskey="s"> <-- Its button to post 

现在...

当我在我的应用程序中单击 Button5 时

 private void button5_Click(object sender, EventArgs e)
    {

    }

想要。

  1. 转到 Link(Link 转到 post 网站)

  2. 从“textBox1_tytul”windows 应用复制文本以在网站上放置标题

  3. 将文本从“textBox1_output”windows 应用程序复制到 Place 以在网站上输入

  4. 在网站上点击按钮post

  5. 在我的 windows 应用程序中显示提醒“条目已添加”

    string message = "已添加条目";
    MessageBox.Show(留言);

我是初学者,我不知道怎么做...任何帮助,对不起我的英语

我认为您最好使用 class HttpClient。 例如我从
复制了一段代码 https://zetcode.com/csharp/httpclient/ 我的意思是你必须通过 HttpClient 发出 Http 请求。 我希望我能理解你的问题并帮助你

using System;
using System.Text;
using System.Net.Http;
using Newtonsoft.Json;

var person = new Person("John Doe", "gardener");

var json = JsonConvert.SerializeObject(person);
var data = new StringContent(json, Encoding.UTF8, "application/json");

var url = "https://httpbin.org/post";
using var client = new HttpClient();

var response = await client.PostAsync(url, data);

string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);

record Person(string Name, string Occupation);