2

I have successfully deployed an ASP.NET Core 2.0 (MVC) on Win IoT Core (running on Rasp Pi 3). The device is listening on 192.168.0.14:80.

enter image description here

I activate the application via PowerShell (from my host computer connected to the device) as follows.

enter image description here

The problem is that if I close the PowerShell window, the server stop listening.

Question

How to active the web application as a service that is always running even after restarting the device?

Second Person Shooter
  • 14,188
  • 21
  • 90
  • 165

1 Answers1

1

You should try connectin to the RPi:

Enter-PSSession -ComputerName <Raspberry IP> -Credential <Raspberry IP>\Administrator

And then schedule a task:

schtasks /create /tn "Startup Web" /tr c:\Startup.bat /sc onstart /ru SYSTEM

Where startup.bat executes a powershell script with something like:

Set-Location C:\publish\ .\aspnet.on.rpi.exe

Check this post for a complete sample: https://carlos.mendible.com/2017/03/26/raspberry-pi-run-aspnet-core-on-startup/

Carlos Mendible
  • 331
  • 1
  • 9
  • 1
    There shouldn't be any problem running something like: schtasks /create /tn "Startup Web" /tr c:\publish\aspnet.on.rpi.exe /sc onstart /ru SYSTEM I use the powershell script to run more things and checks at startup. – Carlos Mendible Sep 11 '17 at 08:28
  • 1
    If you don't use the batch file the you need to invoke powershell.exe within the schtask command. Something like: schtasks.exe /create /tn "Startup Web" /sc onstart /tr "powershell.exe -file C:\startup.ps1" – Carlos Mendible Sep 11 '17 at 08:32