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 ?

  • You cannot add OWIN packages to a universal app in VS 2015 – user34948 Sep 21 '15 at 4:29
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

  • This is a great looking project Tom. I had started playing with a similar idea, creating classes to handle different kinds of http requests, but you and your contributors have really built something cool. Can't wait to try it out. – Ben Brandt May 27 '16 at 14:00
  • Is this your project? Please provide disclaimer on your answer about that. PS Cant you host MVC on IoT? – Piotr Kula Jun 16 '16 at 6:55
  • Indeed my project, disclaimer added. And no, you can't host MVC on IoT. – Tom Kuijsten Jun 17 '16 at 9:08
  • Indeed. MVC requires either IIS or .NET Core, neither of which are supported (yet) on Win IoT. Eventually .NET Core will be supported though. – Jim Yarbro Jul 31 '16 at 13:36
  • @TomKuijsten Thank you for your contribution. If I may ask, would you still suggest I use your implementation? Is it "up to date", cause I see the current thread is from 3 years ago. If not, do you have an alternative in mind? – Thodoris Koskinopoulos Sep 30 '18 at 16:11
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!

  • Thank you for info, yes, I want mentioned Windows Universal App with ASP.NET 4 or 5 self-hosted, however not sure about this when using Universal App instead of simple console app. Use of OWIN web server in .net is not allowed for Windows Universal App projects, or only for IoT.. – Hrvoje Kusulja Jun 11 '15 at 12:24
  • Hi, I am after the same thing but am not bothered by using OWIN. I would just like to server html pages via my raspberry pi2 with windows 10 installed. there is no default page to my device? – Andrew Simpson Oct 25 '15 at 18:29
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.