windows service has start and stop function. from win service start function we like to start web api like this way
string baseAddress = "http://localhost:9000/"; // Start OWIN host using (WebApp.Start<Startup>(url: baseAddress)) { // Create HttpCient and make a request to api/values HttpClient client = new HttpClient(); HttpResponseMessage response = client.GetAsync(baseAddress + "api/Values/TestGet1").Result; response.Headers.Remove("Server"); Console.WriteLine(response); Console.WriteLine(response.Content.ReadAsStringAsync ().Result); Console.ReadLine(); }
but how to stop the service when stop function will fire in windows service ?
i am looking for complete small code.