1. HttpListener httpListener = new HttpListener();
    2. httpListener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
    3. httpListener.Prefixes.Add("http://localhost:8080/");
    4. httpListener.Start();
    5. new Thread(new ThreadStart(delegate
    6. {
    7. while (true)
    8. {
    9. HttpListenerContext httpListenerContext = httpListener.GetContext();
    10. httpListenerContext.Response.StatusCode = 200;
    11. httpListenerContext.Response.ContentType = "text/html";
    12. byte[] bytes = File.ReadAllBytes(@"单页文件路径");
    13. httpListenerContext.Response.OutputStream.Write(bytes, 0, bytes.Length);
    14. }
    15. }))
    16. { IsBackground = true }.Start();