12

Currently Windows 10 Core for IoT is in Preview, and there is available to use Visual Studio 2015 RC with new Windows Universal project and develop some apps.

However, I am interested in making my own ASP.NET WebAPI (REST / JSON) on Raspberry Pi 2 as a host. Is it possible ? Also is it possible for RPi2 to be a small web server with few .html files at all ?

Hrvoje Kusulja
  • 385
  • 1
  • 4
  • 9

4 Answers4

10

If your looking for a simple REST service for a windows universal app, take a look at this github project:

https://github.com/tomkuijsten/restup

There is also a nuget package for it:

https://www.nuget.org/packages/Restup/

Disclaimer: I'm the owner and creator of restup

Tom Kuijsten
  • 201
  • 2
  • 4
4

Also check out Embedded HTTP and WebSocket Server for UWP/.NET 4.5 https://www.nuget.org/packages/IotWeb/ (or on github)

3

It's possible to implement a web server with Windows 10 Core for IoT on the Raspberry Pi 2. If you access your device on http://devicename/, you will actually see a website that is already provided by the system.

To implement your own web server on Windows IoT, there are a bunch of possibilities. For Python or Node.js, there are already samples available on the official GitHub project:
https://github.com/ms-iot/samples

As you mentioned ASP.NET: I didn't stumble across any sample yet, but you should be able to do that, either with a classic self-hosted ASP.NET 4 application or you could give it a try with ASP.NET 5 (aka "ASP.NET vNext").

In both cases, you should create a Windows Universal App first, which will host the web server. Now, you can follow the same approach as described in several tutorials out there that demonstrate how to implement a self-hosted ASP.NET server, e.g. using a console application. Instead of a console application you are using the Windows Universal App here, but that basically doesn't make a difference.

ASP.NET 4 sample :
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

ASP.NET 5 sample:
http://www.c-sharpcorner.com/UploadFile/7ca517/Asp-Net-5-conaole-application-with-visual-studio-2015/

Hope that helps!

Daniel Lemke
  • 171
  • 3
0

Note that the "App2App WebServer" sample application uses sockets to listen for a connection. You can easily extend the code to read the content and treat process the content as JSON if you want to do your own simple Restful server. It won't have all the ASP.NET mechanism but then you want simple.