11 12 2017
Running ASP.NET Core 2 applications on Windows 10 IoT Core
It has been problematic to run ASP.NET Core applications on Windows 10 IoT Core as it is not officially supported scenario yet and many components we are used with are not built with Windows 10 ARM in mind. Still it easy to run web applications on Windows 10 IoT Core using ASP.NET Core 2. There are few tricks developers should know when building web applications for Windows 10 IoT Core. This blog post is short guide about ASP.NET Core 2 on Windows 10 IoT Core
Few things to mention before making hands dirty with real stuff:
- ASP.NET Core on Windows 10 IoT Core is not officially supported scenario yet,
- there is only .NET Core runtime available for Windows 10 on ARM but not SDK (yes, there is no dotnet restore and dotnet build etc available),
- not all things that work on dev box will work on Windows 10 IoT Core and some of these things come out when trying to run web application on board.
With these warnings in mind let’s stat at safe waters and make default ASP.NET Core 2 web application run on Windows 10 IoT Core.
Building web application
I created default ASP.NET Core 2 web application with Visual Studio and made compiler build also .exe file that can be run directly. Just open project file and add output type setting.
Now we can build web application just to find out that .exe file is not there. We will get it when publishing application.
Before building and deploying our web application to board we have to make it listen port 5000 on all interfaces. For this we modify porgam class and use * as host name.
public class Program
public static void Main(string args)
public static IWebHost BuildWebHost(string args) =>
To deploy our application to Windows 10 IoT Core we need to publish it and tell dotnet utility that we want to support Windows 10 on ARM. This is done using the following command line.
dotnet publish -r win-arm
If everything went well then published files are in folder bin\Debug\netcoreapp2.0\win-arm\publish.
Size of the publish folder in my case is 73 MB.
Deploying web application to Windows 10 IoT Core
To make simple test run for web application we need to deploy it to Windows 10 IoT Core. Expecting we have one set up and available here are steps to follow.
- Open PowerShell in Administration permissions and run the following command:
Enter-PSSession -ComputerName minwinpc -Credential minwinpc\Administrator
When logon dialog opens enter your Windows 10 IoT Core password.
- Create folder for web application and move to this folder:
- Open Windows Explorer and move to your board’s drive:
Enter password when it is asked and then move to webapptest folder.
- Take files from web application publish folder and copy these to webapptest folder created before.
- Run the following command in PowerShell to open port 5000 of board:
netsh advfirewall firewall add rule name=”ASP.NET Core Web Server port” dir=in action=allow protocol=TCP localport=5000
- Next, in PowerShell, run web application using .exe file:
If there are no problematic dependencies in our web application then we can see some output to PowerShell window.
Notice that ASP.NET Core is listening to port 5000 on all network interfaces. Let’s open application now using browser.
We don’t see any debug output in PowerShell except exceptions if there are some.
NB! First request to web application is very slow but after this web application works fast and doesn’t put much load to board. Most of requests doesn’t consume much CPU and working set of memory is around 104 MB.
Running ASP.NET Core application at system startup
The final thing that caused some issues for me and other readers was getting ASP.NET Core 2 application automatically run when Raspberry boots up. I found excellent guide by Carlos Mendible that helped me out. The point is simple. We have to create DOS batch file to run PowerShell script that actually runs our web application. Batch => PowerShell => WebApplication. After creating these two files we have to register the batch file as scheduled task run once when system starts.
If you were in trouble with this and made experiments that didn’t succeed then please make sure you remove all previous scheduled tasks you created.
Previously it was harder to make ASP.NET Core applications run on Windows 10 IoT Core but with ASP.NET Core 2 we can do it with less effort and hacking. All we had to do to make default web application run on Windows 10 IoT Core was to build it as executable and then publish it to board. It is still risky business as many things that run on usual boxes without any issues are not built with Windows on ARM in mind and issues with these components come usually out when running application on board. Still we can use ASP.NET Core on Windows 10 IoT Core and come out with solutions where simple web server on board is needed.