Receiving of multiple requests with Simple HTTP Server in .NET

The Clever Internet .NET Suite library provides a special SimpleHttpServer component that works in single-threaded blocking mode.

The code below runs the listening in a loop. The requests are accepted until you call to the stop resource name in your web browser.

using (var server = new SimpleHttpServer()) {
	do {

		var request = server.AcceptRequest();
		var uri = server.RequestUri;

		server.ResponseHeader.ContentType = "text/html";
		server.KeepConnection = false;

		if (uri.IndexOf("stop") > -1) {
			server.SendResponse(200, "OK", "<html><body>Server stopped.</body></html>");

		server.SendResponse(200, "OK", "<html><body>Your requested the " + uri + " resource.</body></html>");
	while (true);

Add Feedback