using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; namespace HttpTest.HttpService { public class CustomHttpServer : HttpServerBase { public CustomHttpServer(int maxThreads) : base(maxThreads) { } protected override void ProcessHttpRequest(HttpListenerContext ctx) { Console.WriteLine("You can do anything......"); string response = "Hello World!"; byte[] buffer = Encoding.UTF8.GetBytes(response); ctx.Response.StatusCode = 200; ctx.Response.ContentLength64 = buffer.Length; ctx.Response.OutputStream.Write(buffer, 0, buffer.Length); ctx.Response.OutputStream.Close(); ctx.Response.Close(); } } }