Cromon

Untitled

Aug 24th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1.         private void WriteErrorResponse(System.Net.HttpStatusCode code, string text)
  2.         {
  3.             HttpRequest req = new HttpRequest();
  4.             req.StatusCode = code;
  5.  
  6.             var str = "<html><body><h1>" + ((int)code).ToString("D3") + " - " + code.ToString() + "</h1><br/>";
  7.             str += text + "</body></html>";
  8.  
  9.             var bytes = Encoding.UTF8.GetBytes(str);
  10.             req.ResponseStream.Write(bytes, 0, bytes.Length);
  11.  
  12.             req["Content-Length"] = bytes.Length;
  13.             req["Connection"] = "close";
  14.  
  15.             Send(req);
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment