Dot Net Core Log Request URL
The dotnet request pipeline is really nice. It kinda feels like using middleware with express in node.
The following middleware will add a lot entry about which controller and method were called.
app.Use(async (context, next) =>
{
var routeData = context.GetRouteData();
var controller = routeData.Values.ContainsKey("controller")
? routeData.Values["controller"].ToString()
: string.Empty;
var action = routeData.Values.ContainsKey("action")
? routeData.Values["action"].ToString()
: string.Empty;
logger.Debug($"Controller Action Called. Controller: { controller } - Method: { action }");
await next();
});