{
try {
HttpContext ctx = HttpContext.Current;
- if (ctx != null && ctx.IsCustomErrorEnabled)
- return GetCustomErrorDefaultMessage ();
+ if (ctx != null && ctx.IsCustomErrorEnabled) {
+ if (http_code != 404 && http_code != 403)
+ return GetCustomErrorDefaultMessage ();
+ else
+ return GetDefaultErrorMessage (false);
+ }
if (!(this.InnerException is HtmlizedException))
- return GetDefaultErrorMessage ();
+ return GetDefaultErrorMessage (true);
return GetHtmlizedErrorMessage ();
} catch (Exception ex) {
void WriteFileBottom (StringBuilder builder, bool showTrace)
{
- builder.Append ("<hr style=\"color: silver\"/>");
- builder.AppendFormat ("<strong>Version information: </strong> Mono Version: {0}; ASP.NET Version: {0}</body></html>\r\n<!--", Environment.Version);
- if (!showTrace)
- return;
-
- string trace, message;
- bool haveTrace;
- Exception ex = this;
+ if (showTrace) {
+ builder.Append ("<hr style=\"color: silver\"/>");
+ builder.AppendFormat ("<strong>Version information: </strong> Mono Version: {0}; ASP.NET Version: {0}</body></html>\r\n", Environment.Version);
- while (ex != null) {
- trace = ex.StackTrace;
- message = ex.Message;
- haveTrace = (trace != null && trace.Length > 0);
+ string trace, message;
+ bool haveTrace;
+ Exception ex = this;
+
+ builder.Append ("\r\n<!--");
+ while (ex != null) {
+ trace = ex.StackTrace;
+ message = ex.Message;
+ haveTrace = (trace != null && trace.Length > 0);
- if (!haveTrace && (message == null || message.Length == 0)) {
- ex = ex.InnerException;
- continue;
- }
+ if (!haveTrace && (message == null || message.Length == 0)) {
+ ex = ex.InnerException;
+ continue;
+ }
- builder.Append ("\r\n[" + ex.GetType () + "]: " + HtmlEncode (message) + "\r\n");
- if (haveTrace)
- builder.Append (ex.StackTrace);
+ builder.Append ("\r\n[" + ex.GetType () + "]: " + HtmlEncode (message) + "\r\n");
+ if (haveTrace)
+ builder.Append (ex.StackTrace);
- ex = ex.InnerException;
- }
+ ex = ex.InnerException;
+ }
- builder.Append ("\r\n-->");
+ builder.Append ("\r\n-->");
+ } else
+ builder.Append ("</body></html>\r\n");
}
string GetCustomErrorDefaultMessage ()
return builder.ToString ();
}
- string GetDefaultErrorMessage ()
+ string GetDefaultErrorMessage (bool showTrace)
{
Exception ex, baseEx;
ex = baseEx = GetBaseException ();
builder.Append ("</p>\r\n");
if (resource_name != null && resource_name.Length > 0)
- builder.AppendFormat ("<p><strong>Resource URL: </strong>{0}</p>\r\n", resource_name);
+ builder.AppendFormat ("<p><strong>Requested URL: </strong>{0}</p>\r\n", resource_name);
- if (baseEx != null && http_code != 404) {
+ if (showTrace && baseEx != null && http_code != 404 && http_code != 403) {
builder.Append ("<p><strong>Stack Trace: </strong></p>");
builder.Append ("<table summary=\"Stack Trace\" class=\"sampleCode\">\r\n<tr><td>");
WriteTextAsCode (builder, baseEx.ToString ());
builder.Append ("</td></tr>\r\n</table>\r\n");
}
- WriteFileBottom (builder, true);
+ WriteFileBottom (builder, showTrace);
return builder.ToString ();
}