C# Asp.net core middleware for redirecting URLs
If you add IWebHostEnvironment as a dependency to the middleware class, you can simplify the environment check by this:
if (webHostEnvironment.IsDevelopment())
{
        
}