public static ActionResult SendHtml(this HttpListenerResponse response, HtmlResponse r) { //Buffer byte[] buffer = new byte[r.BufferSize]; //Content type response.ContentType = "text/html"; //Get string resource string content = r.Content; if (r.ReplaceDict != null) { foreach (string key in r.ReplaceDict.Keys) { content = content.Replace(key, r.ReplaceDict[key]); } } //open output stream using (var net = response.OutputStream) { using (Stream st = new MemoryStream(r.Encode.GetBytes(content))) { while (true) { int count = st.Read(buffer, 0, buffer.Length); if (count <= 0) { break; } net.Write(buffer, 0, count); } } } //end write return(ActionResult.Handled); }
public static ActionResult SendHtml(this HttpListenerResponse response, HtmlResponse r) { //Buffer byte[] buffer = new byte[r.BufferSize]; //Content type response.ContentType = "text/html"; //Get string resource string content = r.Content; if (r.ReplaceDict != null) { foreach (string key in r.ReplaceDict.Keys) { content = content.Replace(key, r.ReplaceDict[key]); } } //open output stream using (var net = response.OutputStream) { using (Stream st = new MemoryStream(r.Encode.GetBytes(content))) { while (true) { int count = st.Read(buffer, 0, buffer.Length); if (count <= 0) break; net.Write(buffer, 0, count); } } }//end write return ActionResult.Handled; }