【问题标题】:How to Call Web API in Asp.Net WebForm?如何在 Asp.Net WebForm 中调用 Web API?
【发布时间】:2020-10-13 11:19:36
【问题描述】:

我想在 C# 中调用这个 API,会传递相同的参数。

在 POSTMAN 上运行良好;我只想从 asp.net Web Form 调用

【问题讨论】:

  • 是什么阻止了你?您在寻找HttpClient 吗?
  • 我不知道如何传递多个参数我
  • 我想 cal 因为它来自代码后面/后端
  • 请勿将代码粘贴为截图;而是复制并粘贴文本。它还将使那些使用屏幕阅读器或其他辅助文本功能的人受益,而图像不会。

标签: c# asp.net api asp.net-web-api


【解决方案1】:

使用那个:

var values = new Dictionary<string, string>
{
    { "thing1", "hello" },
    { "thing2", "world" }
};

var content = new FormUrlEncodedContent(values);

var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);

var responseString = await response.Content.ReadAsStringAsync();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-29
    • 2023-03-26
    • 2021-09-16
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    • 2020-11-21
    相关资源
    最近更新 更多