Example #1
0
        public static void SendError(HttpResponse res, HttpStatusCode code, string s, params object[] args)
        {
            var msg = string.Format(s, args);
            var err = HttpStatusCodes.GetStatusString(code);

            res.ContentType = "text/html";
            SetStatus(res, code);

            var responseString = new StringBuilder();

            responseString.AppendFormat("<html><head><title>{0} {1}</title></head><body bgcolor=#FFFFFF><h2>{2}</h2>",
                                        (int)code, err, err);
            responseString.Append(EscapeHTML(msg));
            Logger.Log.Error(string.Format("HttpRequest error: {0} {1}", (int)code, msg));
            responseString.AppendFormat("<hr><a href='{0}'><font size=-1>{1}</font></a></body></html>", SERVER_URL,
                                        GetServer());

            using (var writer = new StreamWriter(res.OutputStream))
            {
                writer.Write(responseString.ToString());
            }
        }
Example #2
0
 public static void SetStatus(HttpResponse res, HttpStatusCode code)
 {
     res.StatusCode        = (int)code;
     res.StatusDescription = HttpStatusCodes.GetStatusString(code);
 }