ASP.NET Core MVC Middleware for redirecting old paths to new paths using either 301 or 302 redirects
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Route URL Redirector Middleware for ASP.NET Core MVC

A super-simple fluent API for preserving your website's link juice and traffic by redirecting legacy routes in ASP.NET Core MVC.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    app.UseRequestRedirect(redirect =>
        // Permanently redirect (emits 301 redirect to search engines)

        // Temporary redirect (emits 302 redirect to search engines)

Need to query a database for a URL? We've got you covered!

If you need to query a database or other location for a URL then you can also do the following:

app.UseRequestRedirect(redirect =>

private string DeferredQueryDbForPath(string oldPath){
    /* Query database for new path only if old path is hit */
    return newPath;

Note: The lookup method will only be executed if, and only if the ForPath URL is hit.


You can install Route URL Redirector by copying and pasting the following command into your Package Manager Console within Visual Studio (Tools > NuGet Package Manager > Package Manager Console).

Install-Package RouteUrlRedirector

Then all you need to do is call the app.UseRequestRedirect(...) extension method in your Configure method within Startup.cs to add Route URL Redirector to your pipeline and configure your URLs as above.