public async Task Invoke(HttpContext httpContext, IAmateurPoetry amateurPoetry02) { IAmateurPoetry amateurPoetry03 = httpContext.RequestServices.GetRequiredService <IAmateurPoetry>(); Debug.WriteLine("=====================Request starting====================="); await _nextDelegate.Invoke(httpContext); Debug.WriteLine($"[_amateurPoetry]{_amateurPoetry.InterfaceMethodMustImpleInDerivedClass()}"); Debug.WriteLine($"[amateurPoetry02]{amateurPoetry02.InterfaceMethodMustImpleInDerivedClass()}"); Debug.WriteLine($"[amateurPoetry03]{amateurPoetry03.InterfaceMethodMustImpleInDerivedClass()}"); Debug.WriteLine("=====================Request complete====================="); }
public IActionResult Index() { /*发送大量请求时,建议用HttpClientFactory实现HttpHandler的复用*/ //HttpClient httpClient = new HttpClient(); //var result = WebHelper.GetWebPageSourceCode(new Uri("https://www.baidu.com")).Result; string poemTitle = "LiXuePian"; ViewData["amateurPoetryUniqueInfo"] = _amateurPoetry.InterfaceMethodMustImpleInDerivedClass(); ViewData["amateurPoetry"] = _amateurPoetry.AmateurPoetryStyle(poemTitle); ViewData["professionalPoetryUniqueInfo"] = _professionalPoetry.InterfaceMethodMustImpleInDerivedClass(); ViewData["professionalPoetry"] = _professionalPoetry.ProfessionalPoetryStyle(poemTitle); return(View()); }