i got a WinForms Project with a WebAPI inside. The WinForms is used to setup all and the API is needed to fetch data from anywhere else. Is it possible, that i start the Web API via Code after the Setup? Or how can i secure, that always API and WinForms is running?
EDIT: To make it more clear. I got a Web Applicatio, that fetches Data from a Server. To get this data i developed an API. But I'd like to keep the server flexibel. This could maybe change. So my thought was, that I could Setup/Seelect the Server in a WinForms and start in the Background the API. My question is now, is there a possibility to setup the API in the Background of the WinForms and keep the API running after Forms is closed? Hope now is more clear, what I want to do.
You can start a self host webAPI server using a .net task in this simple way:
webServer = WebHost.CreateDefaultBuilder()
.ConfigureServices(services =>
{
// configure your services here
//services.AddMvc(...
})
.Configure(app =>
{
// configure your app here
//app.UseMvc();
})
.Build();
await webServer.StartAsync();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.