How do we host WebAPI as a windows service using same mechanism?
My project was originally created with VS2019 WebApi Template
What I am starting to do is replace services.AddHostedService<ServiceA>(); with services.AddControllers();
and added
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
in the Configure method of Startup.
Am I in the right path?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: b0bd8cb8-7e28-8c4d-a550-3aea8f3ab4dd
- Version Independent ID: 4b60d24e-ef05-15e5-10b4-483094081bf3
- Content: Host ASP.NET Core in a Windows Service
- Content Source: aspnetcore/host-and-deploy/windows-service.md
- Product: aspnet-core
- Technology: aspnetcore-hostdeploy
- GitHub Login: @guardrex
- Microsoft Alias: riande
Yes ... and you see that we're going to go with a Razor Pages sample. We'll likely add a non-web sample, but we probably won't have three to include an MVC version. The latest guidance for MVC is in the MVC node of the Web apps topics, and you can see the latest changes for 3.0 in the migration topic ... https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
I'll be working on this topic today actually. I'll see about the possibility of having an MVC cross-link along with a Razor Pages cross-link where it will address web app-based services versus background apps (non-web app based services ... no UI).
Let's leave this open ... I'll mark the PR for it, and this issue will close automatically when the PR merges.
Thanks for commenting.
Thank you, it's tricky when there are so many pieces of the framework changing. We need all of them to work in harmony to produce apps.