2009-06-04 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web / HttpException.cs
index 1280c1a410c310f0c1b5667cffe051c69e6b6dcc..6385ffe7cb325273c38e77e17cc1d297dcaada43 100644 (file)
@@ -134,7 +134,7 @@ namespace System.Web
                        try {
                                HttpContext ctx = HttpContext.Current;
                                if (ctx != null && ctx.IsCustomErrorEnabled) {
-                                       if (http_code != 404)
+                                       if (http_code != 404 && http_code != 403)
                                                return GetCustomErrorDefaultMessage ();
                                        else
                                                return GetDefaultErrorMessage (false);
@@ -215,33 +215,35 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
                
                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;
+                       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);
                        
-                       string trace, message;
-                       bool haveTrace;
-                       Exception ex = this;
-                       
-                       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 ()
@@ -320,7 +322,7 @@ table.sampleCode {{width: 100%; background-color: #ffffcc; }}
                        if (resource_name != null && resource_name.Length > 0)
                                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 ());