I'm running a headed application on my Raspberry without any user input (just a display). Since I'd like to change some things in my application I'd like to implement a Webserver and a website where I can adjust some sttings.

I found already how to implement a webserver on this website. But how to display and control HTML elements from c#? Maybe using Node.js?

  • 1
    You cannot run more than one app at the same time if that is what you are trying to do. You can spawn a webserver from within your main app though. I am not sure what you mean "how to control HTML elements" That is typically done by serving HTML files from the webserver. Node.JS is doing stuff on the server by writing JS in HTML files served from another server or static file. I think you may be experiencing a learning curve here. – Piotr Kula Mar 14 '17 at 9:02

As far as I can tell your link is obsolete. Nowadays if you're talking C# and webserver you should be talking Kestrel (ASP.Net Core). I mean seriously, from the link you have provided:

var listener = new StreamSocketListener();

await listener.BindServiceNameAsync("8081");

listener.ConnectionReceived += async (sender, args) =>
  var request = new StringBuilder();

  using (var input = args.Socket.InputStream)
    var data = new byte[BufferSize];
    IBuffer buffer = data.AsBuffer();
    var dataRead = BufferSize;

    while (dataRead == BufferSize)
      await input.ReadAsync(
           buffer, BufferSize, InputStreamOptions.Partial);
                                    data, 0, data.Length));
      dataRead = buffer.Length;

  string query = GetQuery(request);

  using (var output = args.Socket.OutputStream)
    using (var response = output.AsStreamForWrite())
       var html = Encoding.UTF8.GetBytes(
       $"<html><head><title>Background Message</title></head><body>Hello from the background process!<br/>{query}</body></html>");
       using (var bodyStream = new MemoryStream(html))
         var header = $"HTTP/1.1 200 OK\r\nContent-Length: {bodyStream.Length}\r\nConnection: close\r\n\r\n";
         var headerArray = Encoding.UTF8.GetBytes(header);
         await response.WriteAsync(headerArray,
                                   0, headerArray.Length);
         await bodyStream.CopyToAsync(response);
         await response.FlushAsync();

Writing your web server? Are you kidding? There's no excuse to pull forward this "a web server as a trivial entity" nonsense. Web servers are NOT hello world programs. I strongly suggest against writing your own "web server". Just don't. It's a fertile breeding ground for bugs and security issues. Are you going to play the "i'm just learning" card? Then learn something useful: using a library/framework!

If you want to try node.js that's a better idea. In my experience for simple stuff it is very viable.


As I understand it, Windows 10 IoT does not run background apps. It is limited to one app per device in that sense.

  • It is definitely possible - if you follow my link and try this you would see this. – ChristophH Feb 18 '17 at 7:38
  • 4
    You cannot run several "user" background apps. Services and tasks from the core system run threaded. The users application can spawn multiple threads from within the application though but you cannot run several user applications like on a traditional desktop. The purpose of IoT is for a single application to run on the embedded device. For example you do not run firewalls on your CCTV or a media centre on your off the shelf router.. Just to put Windows IoT into perspective here- It is not trying to be a full OS like Raspbian. – Piotr Kula Mar 14 '17 at 8:58

It's not clear what the setup is here. If you're trying to remotely manipulate the webpage displayed on the Pi, you may be able to host the page someplace else and just have the page refresh periodically (assuming the Pi has network access).

If you are hosting on the Pi and need to send updates to it, you could potentially use a Windows-compatible websocket library (e.g. SignalR) to manage communications and send data / commands to the Pi's browser that way. This could also work if it's hosted somewhere else, so you aren't reloading the entire page each time.

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.