WebHostWindowsServiceExtensions.RunAsService(IWebHost) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Runs the specified web application inside a Windows service and blocks until the service is stopped.
public:
[System::Runtime::CompilerServices::Extension]
static void RunAsService(Microsoft::AspNetCore::Hosting::IWebHost ^ host);
public static void RunAsService (this Microsoft.AspNetCore.Hosting.IWebHost host);
static member RunAsService : Microsoft.AspNetCore.Hosting.IWebHost -> unit
<Extension()>
Public Sub RunAsService (host As IWebHost)
Parameters
Examples
This example shows how to use RunAsService(IWebHost).
public class Program
{
public static void Main(string[] args)
{
var config = WebHostConfiguration.GetDefault(args);
var host = new WebHostBuilder()
.UseConfiguration(config)
.Build();
// This call will block until the service is stopped.
host.RunAsService();
}
}