1
2
3
@page "/" @inject HttpClient http <h1>Hello, world!</h1> <button @onclick="@do1">测试</button> @code{ public async void do1() { using var response = await http.GetAsync("22.txt"); using var stream = await response.Content.ReadAsStreamAsync(); StreamReader sr = new StreamReader(stream); var str = sr.ReadToEnd(); Console.WriteLine(str); } }
原文:https://www.cnblogs.com/ligenyun/p/15116403.html