I have a desktop application built using .NET Framework 4.7.2. Now I have a requirement to build a rest API layer with it using which the functionality of the desktop application can be tested with other test tools I have.
So I need to start a web API on demand. Is there any way to start and stop a web API on-demand in .NET Framework 4.7.2?
CodePudding user response:
The key word to look for in this context is "self-hosting". This means that your process hosts a HTTP server that can be accessed from clients - e.g. a test tool as in your case.
This documentation shows a sample that uses ASP.NET 4.x.
In order to only start the server when needed, you could add a configuration setting.