public string GetHtmlErrorMessage ()
{
var values = new ExceptionPageTemplateValues ();
ExceptionPageTemplate template = PageTemplate;
try {
values.Add (ExceptionPageTemplate.Template_RuntimeVersionInformationName, RuntimeHelpers.MonoVersion);
values.Add (ExceptionPageTemplate.Template_AspNetVersionInformationName, Environment.Version.ToString ());
HttpContext ctx = HttpContext.Current;
ExceptionPageTemplateType pageType = ExceptionPageTemplateType.Standard;
if (ctx != null && ctx.IsCustomErrorEnabled) {
if (http_code != 404 && http_code != 403) {
FillDefaultCustomErrorValues (values);
pageType = ExceptionPageTemplateType.CustomErrorDefault;
} else
FillDefaultErrorValues (false, false, null, values);
} else {
Exception ex = GetBaseException ();
if (ex == null)
ex = this;
values.Add (ExceptionPageTemplate.Template_FullStackTraceName, FormatFullStackTrace ());
HtmlizedException htmlException = ex as HtmlizedException;
if (htmlException == null)
FillDefaultErrorValues (true, true, ex, values);
else {
pageType = ExceptionPageTemplateType.Htmlized;
FillHtmlizedErrorValues (values, htmlException, ref pageType);
}
}
return template.Render (values, pageType);
} catch (Exception ex) {
Console.Error.WriteLine ("An exception has occurred while generating HttpException page:");
Console.Error.WriteLine (ex);
Console.Error.WriteLine ();
Console.Error.WriteLine ("The actual exception which was being reported was:");
Console.Error.WriteLine (this);
// we need the try/catch block in case the
// problem was with MapPath, which will cause
// IsCustomErrorEnabled to throw an exception
try {
FillDefaultCustomErrorValues (values);
return template.Render (values, ExceptionPageTemplateType.CustomErrorDefault);
} catch {
return DoubleFaultExceptionMessage;
}
}
}