Simple html+image webserver

Aug 5, 2010 at 8:14 PM
Edited Aug 5, 2010 at 8:21 PM
I've to integrate into my c# application a simple web server which, upon request, sends an html page with an image inside of it. I've found your project and I'm trying to integrate it into my application. Using the example now I can send the html page correctly, however I can't send the image. Here is my code: image i; -> created in other part of the application private void OnRequest(object sender, HttpServer.RequestEventArgs e) { e.Response.Connection.Type = HttpServer.Headers.ConnectionType.Close; if (e.Request.Uri.LocalPath == "/") { byte[] buffer = Encoding.UTF8.GetBytes("HTML PAGE WITH IMG TAG INSIDE"); e.Response.Body.Write(buffer, 0, buffer.Length); } else if (e.Request.Uri.LocalPath == "/image.bmp") { MemoryStream stream = new MemoryStream(); i.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); Byte[] bytes = stream.ToArray(); e.Response.Body.Write(bytes, 0, bytes.Length); //e.Context.Stream.Write(bytes, 0, bytes.Length); } } Can anyone help me? Thank you!