As convenient as MVC routing is, there are, however, times when we need to present different URLs to the public, or vice versa—be able to accept a URL that the public knows about. This is where URL rewriting comes in.
URL rewriting is not new; it's been around since ASP.NET Web Forms, natively, and in a more advanced way, through the IIS URL Rewrite module (see https://www.iis.net/downloads/microsoft/url-rewrite). ASP.NET Core offers similar functionality through the Microsoft.AspNetCore.Rewrite package. Let's see how it works.
Essentially, URL rewriting is a feature by which you can turn request URLs into something different based on a set of preconfigured rules. Microsoft suggests some situations where this may come in handy:
- Providing unchanging URLs for resources that need to be changed, temporarily or permanently
- Splitting request across apps
- Reorganizing URL fragments ...