I have implemented something similar to this only real difference is
string filename = context.Request.RawUrl.Replace(\"/\", \"\\\\\").Remove(0,1); string p
Try:
using (Stream s = context.Response.OutputStream) { s.Write(msg, 0, msg.Length); s.Flush() }