Registering ASP.NET Core Site as Windows Service

This post explains how to register an ASP.NET Core website as a Windows service via NSSM.

To register an ASP.NET Core website as a Windows service, you can use NSSM (Non-Sucking Service Manager).

Here are the general steps:

  1. Download NSSM and extract the files to a folder on your computer.
  2. Open a command prompt as an administrator and navigate to the folder containing the NSSM executable.
  3. Run the following command to create a new service: nssm install <service name>
  4. In the NSSM Service Installer window, click the "Browse" button next to the "Path" field and select the executable for your ASP.NET Core web app.
  5. In the "Startup directory" field, enter the directory containing your ASP.NET Core web app's executable.
  6. In the "Arguments" field, enter the command-line arguments for your ASP.NET Core web app (e.g. --urls=http://localhost:5000).
  7. Click "Install service" to create the new service.

After the service is installed, you can start and stop it using the Services app in Windows. Note that you may need to adjust the security settings for the service to allow it to interact with the desktop or access network resources, depending on your app's requirements.