Creating a web server in C#
This basically replicates the “Simple C# Web Server” that is done over at "David’s" Blog: https://codehosting.net/blog/BlogEngine/post/Simple-C-Web-Server I use pretty much the same code – I have given the code the once-over using Re-Sharper. Other than that, the only real difference is that this post actually tells you how to get started and how to demonstrate the thing – useful info for complete newbies, I think. In Visual Studio create a new Console Application: In Program.cs we update the code to include the WebServer class which initializes the HttpListener prefixes – these represent the collection of prefix(s) used to store Uniform Resource Identifier (URI) values for the HttpListener object. The WebServer class also implements methods to run and stop the web service. The main program thread creates an instance of the web server, and runs it as a background thread, and which is stopped whenever the user presses any key. The thread runs the while loo...