public async Task InvokeAsync(HttpContext context, IGuidServiceTransient _guidServiceTransient, IGuidServiceSingleton _guidServiceSingleton, IGuidServiceScoped _guidServiceScoped) { var logMessage = $"Middleware: The Guid from GuidServiceTransient is {_guidServiceTransient.GetGuid()}" + $"The Guid from GuidServiceSingleton is {_guidServiceSingleton.GetGuid()}" + $"The Guid from GuidServiceScoped is {_guidServiceScoped.GetGuid()}"; _logger.LogInformation(logMessage); context.Items.Add("MiddlewareGuid", logMessage); await Task.WhenAll(_next(context)); }
public IActionResult Index() { var guidTransient = _guidServiceTransient.GetGuid(); var guidSingleton = _guidServiceSingleton.GetGuid(); var guidScoped = _guidServiceScoped.GetGuid(); var logMessage = $"Controller: The Guid from GuidServiceTransient is {guidTransient}" + $"The Guid from GuidServiceSingleton is {guidSingleton}" + $"The Guid from GuidServiceScoped is {guidScoped}"; _logger.LogInformation(logMessage); var messages = new List <string> { HttpContext.Items["MiddlewareGuid"].ToString(), logMessage }; return(Ok(messages)); }