1.创建一个应用台控制程序,可以把Model的引用,用下面的方法拖拽上来(
解决方案里没有这个文件,只是这个文件的引用)
2.Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using TmplWebApiDemo.Models;
namespace TempWebApiClient
{
class Program
{
static void Main(string[] args)
{
Do();
Console.ReadLine();
}
private static async void Do()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:12268/");
var result = await client.GetAsync("students");
var list = await result.Content.ReadAsAsync<IEnumerable<Student>>();
foreach (var item in list)
{
Console.WriteLine(item.Name);
}
}
}
}
null
最后
以上就是无辜大白最近收集整理的关于(3)WebApi客户端调用的全部内容,更多相关(3)WebApi客户端调用内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复