After running a first console app on my Raspberry Pi 3, I had to try ASP.NET Core and API. Two weeks ago when I posted “.NET Core console app running on Raspberry Pi”, I could make API working, but I had no chance with MVC. Today it worked!

This post will describe all steps I had to go through to have an ASP.NET Core MVC application running on my Raspberry Pi 3. I will not repeat the steps needed to install the Ubuntu MATE on the Pi, neither how to install the different tools, e.g., SSH Server, Putty, WinSCP… to have an efficient development environment, you can check the previous post for that.

Again you will need to install the .NET Core 2.0 SDK on your Windows machine. This time I used Windows x64 2.0.0-preview1-005791 which I downloaded as a zip. I unzipped it, and then I added it to the System Path.

So now when I run dotnet with the help flag, I see the following, and I am sure to run the correct version

Next, we will create the ASP.NET Core MVC project using the following

Now we have to adapt the mvc.csproj like this

We removed the PackageTargetFallback and added RuntimeFrameworkVersion, RuntimeIdentifiers.

To get access on the network to our ASP.NET Core MVC application we must first adapt the generated Program.cs file, to add the line .UseUrls(“http://*:8000”)

This code change will instruct the framework to bind to all network cards available on the PI, and thus make the web application accessible from your network.

Then we need to run the restore command

Then we publish

We use WinSCP to copy all the files create in the folder C:\@Projects\pi\mvc\bin\Debug\netcoreapp2.0\ubuntu.16.04-arm32\publish\ to the Raspberry Pi. Then we run the application from Putty

Now we are ready to display our first web page using ASP.NET Core MVC running on the Raspberry Pi 3. The first time your browse the site, it will be slow because the Raspberry Pi needs to compile the Razor Page, but you will finally end in front of

ASP.NET Core MVC on Raspberry PI