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);
request.Append(Encoding.UTF8.GetString(
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.