Example #1
0
        public string GetResponseString()
        {
            StringBuilder responseString = new StringBuilder();

            responseString.Append(Version);
            responseString.Append(" ");
            responseString.Append((int)ResponseCode);
            responseString.Append(" ");
            responseString.Append(ResponseCode.ToReasonPhrase());
            responseString.AppendLine();

            foreach (var header in Headers)
            {
                responseString.Append(header.Key);
                responseString.Append(": ");
                responseString.Append(header.Value);
                responseString.AppendLine();
            }

            responseString.AppendLine();

            responseString.Append(Body);
            responseString.AppendLine();
            responseString.AppendLine();

            return(responseString.ToString());
        }
Example #2
0
        public HttpExceptionResponse(Exception e)
        {
            HttpErrorCodeException eTyped = e as HttpErrorCodeException;

            ResponseCode = (eTyped != null) ? eTyped.ReponseCode : HttpResponseCode.S_500_InternalError;
            Body         = string.Format("<h1>{0} {1}</h1>We are sorry. Something happened.<br>Maybe this can help: {2}",
                                         (int)ResponseCode,
                                         ResponseCode.ToReasonPhrase(),
                                         e.Message);
        }