Windows Core IoT – ASP DotNet Core Razor Pages on a Raspberry PI3

Continuing on based on my prior posts

.Net Core on RPI3

SQLite on RPI3

I am going to explain how to use Windows IoT and ASP .Net Core on a RPI3.

As of version 2.0 we now can create ASP Razor webpages in .NET Core.

Remember that in the past I made some post about Web Matrix

That is in fact the predecessor of ASP .Net Core. Read more here

How to use Razor Pages in ASP.NET Core 2.0

Start with installing the DotNet Core Template to begin with

Run command :

dotnet new Razor -n ASPnetCoreRazor -o C:\CoreIoT\ASPnetCoreRazor

image

Next Run the Template Application on your Windows PC.

Use command :

cd C:\CoreIoT\ASPnetCoreRazor

dotnet Run

image

Voila as simple as that Smile

image

Next Publish it for Windows IoT on a RPI3 Architecture

Run command :

dotnet publish -r win8-arm


image

Copy the files to your RPI3 from C:\CoreIoT\ASPnetCoreRazor\bin\Debug\netcoreapp2.0\win8-arm\publish

image


Connect to RPI3 using PowerShell remote session and start the ASPNetCoreRazor.exe Application

image

No connection … ? Sad smile

image

SOLUTION :

1. You need to open the Firewall Port 5000 on your RPI3 first.

Run command :

netsh advfirewall firewall add rule name=” ASPnetCoreRazor ” dir=in action=allow protocol=TCP localport=5000


image

2. Modify the Template Program.cs script

And add this line : .UseUrls(http://*:5000)


image

Publish again :

dotnet publish -r win8-arm

image

Copy the files back over to your RPI3 :

C:\CoreIoT\ASPnetCoreRazor\bin\Debug\netcoreapp2.0\win8-arm\publish\


Next connect to RPI3 using PowerShell and start the app ….

.\ASPnetCoreRazor.exe


image

Open the browser and go to : http://rpi3:5000

image

It runs as expected !! Smile

So now we know how to create RAZOR pages, the door is open to start experimenting with the RAZOR syntax.

As well as integrating SQLite database using the ASP .NetCore Razor Front End….

Enjoy !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: