[ASP.NET Core MVC Pipeline] Routing Middleware — Route Handler

Middleware Pipeline
Middleware Pipeline
  1. Our Web Server received a request and, since it is a valid request, passed it to our application.
  2. Our application passed the request to our Middleware pipeline which running the request through every middleware until one of them decides to end the request.
  3. The request went through a lot of processes and reached our Routing Middleware.
  4. Our routing middleware will pass the request to our Router who will see if this request matches any known route. If it doesn’t, the middleware will pass the request to the next middleware, or initiate the response.
Let's Code
Let’s Code

The Code

This component suffered a great deal of changes in the way it is structured on the Full .NET Framework in comparison with the .NET Core implementation.

private static RequestDelegate CustomRouteHandler()
{
return async (c) =>
{
await Task.Run(() => c.Response.Redirect("http://azurecoder.net"));
};
}
app.UseMvc(routes =>
{
routes.MapRoute("blog/{*path}", CustomRouteHandler());

// Main Route
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
That's All Folks
That’s All Folks

--

--

Software Development and everything that encircles it :)

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lucas Araujo | Azure Coder

Lucas Araujo | Azure Coder

Software Development and everything that encircles it :)