internal string GetHtmlErrorMessage(bool dontShowSensitiveInfo) { this.PrepareFormatter(); StringBuilder sb = new StringBuilder(); sb.Append("<html"); if (IsTextRightToLeft) { sb.Append(" dir=\"rtl\""); } sb.Append(">\r\n"); sb.Append(" <head>\r\n"); sb.Append(" <title>" + this.ErrorTitle + "</title>\r\n"); sb.Append(" <style>\r\n"); sb.Append(" body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n"); sb.Append(" p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n"); sb.Append(" b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n"); sb.Append(" H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n"); sb.Append(" H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n"); sb.Append(" pre {font-family:\"Lucida Console\";font-size: .9em}\r\n"); sb.Append(" .marker {font-weight: bold; color: black;text-decoration: none;}\r\n"); sb.Append(" .version {color: gray;}\r\n"); sb.Append(" .error {margin-bottom: 10px;}\r\n"); sb.Append(" .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n"); sb.Append(" </style>\r\n"); sb.Append(" </head>\r\n\r\n"); sb.Append(" <body bgcolor=\"white\">\r\n\r\n"); sb.Append(" <span><H1>" + System.Web.SR.GetString("Error_Formatter_ASPNET_Error", new object[] { HttpRuntime.AppDomainAppVirtualPath }) + "<hr width=100% size=1 color=silver></H1>\r\n\r\n"); sb.Append(" <h2> <i>" + this.ErrorTitle + "</i> </h2></span>\r\n\r\n"); sb.Append(" <font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \">\r\n\r\n"); sb.Append(" <b> " + System.Web.SR.GetString("Error_Formatter_Description") + " </b>" + this.Description + "\r\n"); sb.Append(" <br><br>\r\n\r\n"); if (this.MiscSectionTitle != null) { sb.Append(" <b> " + this.MiscSectionTitle + ": </b>" + this.MiscSectionContent + "<br><br>\r\n\r\n"); } this.WriteColoredSquare(sb, this.ColoredSquareTitle, this.ColoredSquareDescription, this.ColoredSquareContent, this.WrapColoredSquareContentLines); if (this.ShowSourceFileInfo) { string displayPath = this.GetDisplayPath(); if (displayPath == null) { displayPath = System.Web.SR.GetString("Error_Formatter_No_Source_File"); } sb.Append(string.Concat(new object[] { " <b> ", System.Web.SR.GetString("Error_Formatter_Source_File"), " </b> ", displayPath, "<b> ", System.Web.SR.GetString("Error_Formatter_Line"), " </b> ", this.SourceFileLineNumber, "\r\n" })); sb.Append(" <br><br>\r\n\r\n"); } ConfigurationErrorsException exception = this.Exception as ConfigurationErrorsException; if ((exception != null) && (exception.Errors.Count > 1)) { sb.Append(string.Format(CultureInfo.InvariantCulture, "<br><div class=\"expandable\" onclick=\"OnToggleTOCLevel1('{0}')\">{1}:</div>\r\n<div id=\"{0}\" style=\"display: none;\">\r\n <br><table width=100% bgcolor=\"#ffffcc\">\r\n <tr>\r\n <td>\r\n <code><pre>\r\n\r\n", new object[] { "additionalConfigurationErrors", System.Web.SR.GetString("TmplConfigurationAdditionalError") })); bool flag = false; try { PermissionSet namedPermissionSet = HttpRuntime.NamedPermissionSet; if (namedPermissionSet != null) { namedPermissionSet.PermitOnly(); flag = true; } int num = 0; foreach (ConfigurationException exception2 in exception.Errors) { if (num > 0) { sb.Append(exception2.Message); sb.Append("<BR/>\r\n"); } num++; } } finally { if (flag) { CodeAccessPermission.RevertPermitOnly(); } } sb.Append(" </pre></code>\r\n\r\n </td>\r\n </tr>\r\n </table>\r\n\r\n \r\n\r\n</div>\r\n"); sb.Append("\r\n <script type=\"text/javascript\">\r\n function OnToggleTOCLevel1(level2ID)\r\n {\r\n var elemLevel2 = document.getElementById(level2ID);\r\n if (elemLevel2.style.display == 'none')\r\n {\r\n elemLevel2.style.display = '';\r\n }\r\n else {\r\n elemLevel2.style.display = 'none';\r\n }\r\n }\r\n </script>\r\n "); } if ((!dontShowSensitiveInfo && (this.Exception != null)) && HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium)) { this.WriteFusionLogWithAssert(sb); } this.WriteColoredSquare(sb, this.ColoredSquare2Title, this.ColoredSquare2Description, this.ColoredSquare2Content, false); if (!dontShowSensitiveInfo && !this._dontShowVersion) { sb.Append(" <hr width=100% size=1 color=silver>\r\n\r\n"); sb.Append(" <b>" + System.Web.SR.GetString("Error_Formatter_Version") + "</b> " + System.Web.SR.GetString("Error_Formatter_CLR_Build") + VersionInfo.ClrVersion + System.Web.SR.GetString("Error_Formatter_ASPNET_Build") + VersionInfo.EngineVersion + "\r\n\r\n"); sb.Append(" </font>\r\n\r\n"); } sb.Append(" </body>\r\n"); sb.Append("</html>\r\n"); sb.Append(this.PostMessage); return(sb.ToString()); }
internal /*public*/ string GetHtmlErrorMessage(bool dontShowSensitiveInfo) { // Give the formatter a chance to prepare its state PrepareFormatter(); StringBuilder sb = new StringBuilder(); // REVIEW: all the derived method should work directly with the string // builder instead of returning a string. sb.Append("<html>\r\n"); sb.Append(" <head>\r\n"); sb.Append(" <title>" + ErrorTitle + "</title>\r\n"); sb.Append(" <style>\r\n"); sb.Append(" body {font-family:\"Verdana\";font-weight:normal;font-size: .7em;color:black;} \r\n"); sb.Append(" p {font-family:\"Verdana\";font-weight:normal;color:black;margin-top: -5px}\r\n"); sb.Append(" b {font-family:\"Verdana\";font-weight:bold;color:black;margin-top: -5px}\r\n"); sb.Append(" H1 { font-family:\"Verdana\";font-weight:normal;font-size:18pt;color:red }\r\n"); sb.Append(" H2 { font-family:\"Verdana\";font-weight:normal;font-size:14pt;color:maroon }\r\n"); sb.Append(" pre {font-family:\"Lucida Console\";font-size: .9em}\r\n"); sb.Append(" .marker {font-weight: bold; color: black;text-decoration: none;}\r\n"); sb.Append(" .version {color: gray;}\r\n"); sb.Append(" .error {margin-bottom: 10px;}\r\n"); sb.Append(" .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }\r\n"); sb.Append(" </style>\r\n"); sb.Append(" </head>\r\n\r\n"); sb.Append(" <body bgcolor=\"white\">\r\n\r\n"); sb.Append(" <span><H1>" + HttpRuntime.FormatResourceString(SR.Error_Formatter_ASPNET_Error, HttpRuntime.AppDomainAppVirtualPath) + "<hr width=100% size=1 color=silver></H1>\r\n\r\n"); sb.Append(" <h2> <i>" + ErrorTitle + "</i> </h2></span>\r\n\r\n"); sb.Append(" <font face=\"Arial, Helvetica, Geneva, SunSans-Regular, sans-serif \">\r\n\r\n"); sb.Append(" <b> " + HttpRuntime.FormatResourceString(SR.Error_Formatter_Description) + " </b>" + Description + "\r\n"); sb.Append(" <br><br>\r\n\r\n"); if (MiscSectionTitle != null) { sb.Append(" <b> " + MiscSectionTitle + ": </b>" + MiscSectionContent + "<br><br>\r\n\r\n"); } WriteColoredSquare(sb, ColoredSquareTitle, ColoredSquareDescription, ColoredSquareContent, WrapColoredSquareContentLines); if (ShowSourceFileInfo) { string fileName = HttpRuntime.GetSafePath(SourceFileName); if (fileName == null) { fileName = HttpRuntime.FormatResourceString(SR.Error_Formatter_No_Source_File); } sb.Append(" <b> " + HttpRuntime.FormatResourceString(SR.Error_Formatter_Source_File) + " </b> " + fileName + "<b> " + HttpRuntime.FormatResourceString(SR.Error_Formatter_Line) + " </b> " + SourceFileLineNumber + "\r\n"); sb.Append(" <br><br>\r\n\r\n"); } // If it's a FileNotFoundException/FileLoadException/BadImageFormatException with a FusionLog, // write it out (ASURT 83587) if (!dontShowSensitiveInfo && Exception != null) { // (Only display the fusion log in medium or higher (ASURT 126827) if (HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Medium)) { for (Exception e = Exception; e != null; e = e.InnerException) { string fusionLog = null; string filename = null; FileNotFoundException fnfException = e as FileNotFoundException; if (fnfException != null) { fusionLog = fnfException.FusionLog; filename = fnfException.FileName; } FileLoadException flException = e as FileLoadException; if (flException != null) { fusionLog = flException.FusionLog; filename = flException.FileName; } BadImageFormatException bifException = e as BadImageFormatException; if (bifException != null) { fusionLog = bifException.FusionLog; filename = bifException.FileName; } if (fusionLog != null && fusionLog.Length > 0) { WriteColoredSquare(sb, HttpRuntime.FormatResourceString(SR.Error_Formatter_FusionLog), HttpRuntime.FormatResourceString(SR.Error_Formatter_FusionLogDesc, filename), HttpUtility.HtmlEncode(fusionLog), false /*WrapColoredSquareContentLines*/); break; } } } } WriteColoredSquare(sb, ColoredSquare2Title, ColoredSquare2Description, ColoredSquare2Content, false); if (!dontShowSensitiveInfo) // don't show version for security reasons { sb.Append(" <hr width=100% size=1 color=silver>\r\n\r\n"); sb.Append(" <b>" + HttpRuntime.FormatResourceString(SR.Error_Formatter_Version) + "</b> " + HttpRuntime.FormatResourceString(SR.Error_Formatter_CLR_Build) + VersionInfo.ClrVersion + HttpRuntime.FormatResourceString(SR.Error_Formatter_ASPNET_Build) + VersionInfo.IsapiVersion + "\r\n\r\n"); sb.Append(" </font>\r\n\r\n"); } sb.Append(" </body>\r\n"); sb.Append("</html>\r\n"); sb.Append(PostMessage); return(sb.ToString()); }