Back to articles
Extending an ASP.NET Core App with External Middleware Using "Hosting Startup"

Extending an ASP.NET Core App with External Middleware Using "Hosting Startup"

via Dev.tojsakamoto

Introduction ASP.NET Core has a feature called "Hosting Startup". It allows us to run additional code when an ASP.NET Core Web application starts up. We can also add middleware through this feature. Using Hosting Startup, we can add middleware to an already-built ASP.NET Core Web application without rebuilding it. The middleware is implemented in a separate assembly that is built independently. The official documentation about Hosting Startup is available here. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/platform-specific-configuration How Hosting Startup Works Let me explain how Hosting Startup works in more detail. Prepare a pre-built assembly (a Hosting Startup assembly) that implements the IHostingStartup interface and is marked with the HostingStartup assembly attribute. Set the environment variable ASPNETCORE_HOSTINGSTARTUPASSEMBLIES to the name of the Hosting Startup assembly created in step 1. Run the separately-built ASP.NET Core application. When the ASP.N

Continue reading on Dev.to

Opens in a new tab

Read Full Article
6 views

Related Articles