Concerned about duplicate URLs in ASP.NET MVC?
Take care of both www and non-www domains. .NET already provides the correct method to handle them.
Using the UseRewriter middleware is the optimal approach.
You can use AddRedirectToNonWww() or AddRedirectToWww() for this purpose.
👉 Adapted from my original post on LinkedIn .
