extend web server to serve static files

Posted by Turtle on Stack Overflow See other posts from Stack Overflow or by Turtle
Published on 2010-04-20T03:00:30Z Indexed on 2010/04/20 3:03 UTC
Read the original article Hit count: 307

Filed under:
|

Hello, I want to extend a web server which is only able to handle RPC handling now. The web server is written in C#. It provides a abstract handler function like following:

public string owsHandler(string request, string path, string param,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)

And I wrote following code to handle image files:

Bitmap queryImg = new Bitmap(path);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
queryImg.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
queryImg.Dispose();
byte[] byteImage = stream.ToArray();
stream.Dispose();
return Convert.ToBase64String(byteImage);

And I test it in the browser, the image is returned but the image dimension info is missed. Shall I add something more to the code? Or is any general way to server static files? I do not want to serve it in a ASP.net server.

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about server