Render() public static méthode

public static Render ( ) : HelperResult
Résultat HelperResult
Exemple #1
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            //
            // Write out the page title and speed bar in the body.
            //

            RenderTitle(writer);

            SpeedBar.Render(writer,
                            SpeedBar.RssFeed.Format(BasePageName),
                            SpeedBar.RssDigestFeed.Format(BasePageName),
                            SpeedBar.DownloadLog.Format(BasePageName),
                            SpeedBar.Help,
                            SpeedBar.About.Format(BasePageName));

            if (_errorEntryList.Count != 0)
            {
                //
                // Write error number range displayed on this page and the
                // total available in the log, followed by stock
                // page sizes.
                //

                writer.RenderBeginTag(HtmlTextWriterTag.P);

                RenderStats(writer);
                RenderStockPageSizes(writer);

                writer.RenderEndTag(); // </p>
                writer.WriteLine();

                //
                // Write out the main table to display the errors.
                //

                RenderErrors(writer);

                //
                // Write out page navigation links.
                //

                RenderPageNavigators(writer);
            }
            else
            {
                //
                // No errors found in the log, so display a corresponding
                // message.
                //

                RenderNoErrors(writer);
            }

            base.RenderContents(writer);
        }
Exemple #2
0
        private void RenderError(HtmlTextWriter writer)
        {
            Debug.Assert(writer != null);

            Error error = _errorEntry.Error;

            //
            // Write out the page title containing error type and message.
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "PageTitle");
            writer.RenderBeginTag(HtmlTextWriterTag.H1);
            HtmlEncode(error.Message, writer);
            writer.RenderEndTag(); // </h1>
            writer.WriteLine();

            SpeedBar.Render(writer,
                            SpeedBar.Home.Format(BasePageName),
                            SpeedBar.Help,
                            SpeedBar.About.Format(BasePageName));

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorTitle");
            writer.RenderBeginTag(HtmlTextWriterTag.P);

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorType");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            HtmlEncode(error.Type, writer);
            writer.RenderEndTag(); // </span>

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorTypeMessageSeparator");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(": ");
            writer.RenderEndTag(); // </span>

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorMessage");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            HtmlEncode(error.Message, writer);
            writer.RenderEndTag(); // </span>

            writer.RenderEndTag(); // </p>
            writer.WriteLine();

            //
            // Do we have details, like the stack trace? If so, then write
            // them out in a pre-formatted (pre) element.
            // NOTE: There is an assumption here that detail will always
            // contain a stack trace. If it doesn't then pre-formatting
            // might not be the right thing to do here.
            //

            if (error.Detail.Length != 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorDetail");
                writer.RenderBeginTag(HtmlTextWriterTag.Pre);
                writer.Flush();
                MarkupStackTrace(error.Detail, writer.InnerWriter);
                writer.RenderEndTag(); // </pre>
                writer.WriteLine();
            }

            //
            // Write out the error log time. This will be in the local
            // time zone of the server. Would be a good idea to indicate
            // it here for the user.
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "ErrorLogTime");
            writer.RenderBeginTag(HtmlTextWriterTag.P);
            HtmlEncode(string.Format("Logged on {0} at {1}",
                                     error.Time.ToLongDateString(),
                                     error.Time.ToLongTimeString()), writer);
            writer.RenderEndTag(); // </p>
            writer.WriteLine();

            //
            // Render alternate links.
            //

            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.Write("See also:");
            writer.RenderEndTag(); // </p>
            writer.WriteLine();

            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            //
            // Do we have an HTML formatted message from ASP.NET? If yes
            // then write out a link to it instead of embedding it
            // with the rest of the content since it is an entire HTML
            // document in itself.
            //

            if (error.WebHostHtmlMessage.Length != 0)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                string htmlUrl = this.BasePageName + "/html?id=" + HttpUtility.UrlEncode(_errorEntry.Id);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, htmlUrl);
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("Original ASP.NET error page");
                writer.RenderEndTag(); // </a>
                writer.RenderEndTag(); // </li>
            }

            //
            // Add a link to the source XML and JSON data.
            //

            writer.RenderBeginTag(HtmlTextWriterTag.Li);
            writer.Write("Raw/Source data in ");

            writer.AddAttribute(HtmlTextWriterAttribute.Href, "xml" + Request.Url.Query);
#if NET_1_0 || NET_1_1
            writer.AddAttribute("rel", HtmlLinkType.Alternate);
#else
            writer.AddAttribute(HtmlTextWriterAttribute.Rel, HtmlLinkType.Alternate);
#endif
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "application/xml");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write("XML");
            writer.RenderEndTag(); // </a>
            writer.Write(" or in ");

            writer.AddAttribute(HtmlTextWriterAttribute.Href, "json" + Request.Url.Query);
#if NET_1_0 || NET_1_1
            writer.AddAttribute("rel", HtmlLinkType.Alternate);
#else
            writer.AddAttribute(HtmlTextWriterAttribute.Rel, HtmlLinkType.Alternate);
#endif
            writer.AddAttribute(HtmlTextWriterAttribute.Type, "application/json");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.Write("JSON");
            writer.RenderEndTag(); // </a>

            writer.RenderEndTag(); // </li>

            //
            // End of alternate links.
            //

            writer.RenderEndTag(); // </ul>

            //
            // If this error has context, then write it out.
            // ServerVariables are good enough for most purposes, so
            // we only write those out at this time.
            //

            RenderCollection(writer, error.ServerVariables,
                             "ServerVariables", "Server Variables");

            base.RenderContents(writer);
        }
Exemple #3
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            //
            // Emit a script that emit version info and checks for updates.
            //

            writer.WriteLine(@"
                <script type='text/javascript' language='JavaScript'>
                    function onCheckForUpdate(sender) {
                        var script = document.createElement('script');
                        script.type = 'text/javascript';
                        script.language = 'JavaScript';
                        script.src = 'http://elmah.googlecode.com/svn/www/update.js?__=' + (new Date()).getTime();
                        document.getElementsByTagName('head')[0].appendChild(script);
                        return false;
                    }
                    var ELMAH = {
                        info : {
                            version     : '" + GetVersion() + @"',
                            fileVersion : '" + GetFileVersion() + @"',
                            type        : '" + Build.TypeLowercase + @"',
                            status      : '" + Build.Status + @"',
                            framework   : '" + Build.Framework + @"',
                            imageRuntime: '" + Build.ImageRuntimeVersion + @"'
                        }
                    };
                </script>");

            //
            // Title
            //

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "PageTitle");
            writer.RenderBeginTag(HtmlTextWriterTag.H1);
            writer.Write(PageTitle);
            writer.RenderEndTag(); // </h1>
            writer.WriteLine();

            //
            // Speed Bar
            //

            SpeedBar.Render(writer,
                            SpeedBar.Home.Format(BasePageName),
                            SpeedBar.Help,
                            SpeedBar.About.Format(BasePageName));

            //
            // Content...
            //

            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.AddAttribute(HtmlTextWriterAttribute.Onclick, "return onCheckForUpdate(this)");
            writer.AddAttribute(HtmlTextWriterAttribute.Title, "Checks if your ELMAH version is up to date (requires Internet connection)");
            writer.RenderBeginTag(HtmlTextWriterTag.Button);
            writer.Write("Check for Update");
            writer.RenderEndTag(); // </button>
            writer.RenderEndTag(); // </p>

            SccStamp[] stamps = SccStamp.FindAll(typeof(ErrorLog).Assembly);
            SccStamp.SortByRevision(stamps, /* descending */ true);

            writer.RenderBeginTag(HtmlTextWriterTag.P);
            writer.Write("This <strong>{0}</strong> ", Build.TypeLowercase);

            if (stamps.Length > 0)
            {
                writer.Write("(SCC #{0}) ", stamps[0].Revision.ToString("N0"));
            }

            writer.Write("build was compiled from the following sources for CLR {0}:", Build.ImageRuntimeVersion);

            writer.RenderEndTag(); // </p>

            //
            // Stamps...
            //

            writer.RenderBeginTag(HtmlTextWriterTag.Ul);

            foreach (SccStamp stamp in stamps)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Li);
                writer.RenderBeginTag(HtmlTextWriterTag.Code);
                Server.HtmlEncode(stamp.Id, writer);
                writer.RenderEndTag(); // </code>
                writer.RenderEndTag(); // </li>
            }

            writer.RenderEndTag(); // </ul>
        }
        public override void Execute()
        {
            WriteLiteral("\r\n");



            WriteLiteral("\r\n");



            #line 11 "..\..\MasterPage.cshtml"

            var basePageName = Request.ServerVariables["URL"];

            var now = DateTime.Now;
            var tz  = TimeZone.CurrentTimeZone;

            var speedBarItems = (SpeedBarItems ?? Enumerable.Empty <SpeedBar.FormattedItem>()).ToArray();



            #line default
            #line hidden
            WriteLiteral("<!DOCTYPE html>\r\n<html>\r\n    <head>\r\n        <meta name=\"referrer\" content=\"no-re" +
                         "ferrer\">\r\n");



            #line 23 "..\..\MasterPage.cshtml"
            if (!string.IsNullOrEmpty(Title))
            {
            #line default
            #line hidden
                WriteLiteral("            <title>");



            #line 25 "..\..\MasterPage.cshtml"
                Write(Title);


            #line default
            #line hidden
                WriteLiteral("</title>\r\n");



            #line 26 "..\..\MasterPage.cshtml"
            }


            #line default
            #line hidden


            #line 27 "..\..\MasterPage.cshtml"



            #line default
            #line hidden
            WriteLiteral(@"        <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
        <!--[if lt IE 9]>
          <script src=""http://afarkas.github.io/html5shiv/src/html5shiv.js""></script>
        <![endif]-->
        <link rel=""stylesheet"" type=""text/css"" href=""");



            #line 32 "..\..\MasterPage.cshtml"
            Write(basePageName);


            #line default
            #line hidden
            WriteLiteral("/stylesheet?h=");



            #line 32 "..\..\MasterPage.cshtml"
            Write(Uri.EscapeDataString(StyleSheetHelper.StyleSheetHash));


            #line default
            #line hidden
            WriteLiteral("\" />\r\n        <style type=\"text/css\">\r\n          body {\r\n            padding-top:" +
                         " 60px;\r\n          }\r\n        </style>\r\n    </head>\r\n    <body>\r\n");



            #line 40 "..\..\MasterPage.cshtml"
            if (speedBarItems.Any())
            {
            #line default
            #line hidden
                WriteLiteral(@"            <div id=""topnavbar"" class=""navbar navbar-fixed-top"">
                <div class=""navbar-inner"">
                    <div class=""container"">
                        <a class=""brand"" href=""https://elmah.github.io/"">ELMAH</a>
                        ");



            #line 46 "..\..\MasterPage.cshtml"
                Write(SpeedBar.Render(speedBarItems));


            #line default
            #line hidden
                WriteLiteral("\r\n                    </div>\r\n                </div>\r\n            </div>\r\n");



            #line 50 "..\..\MasterPage.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("        <div class=\"container-fluid\">\r\n            \r\n            ");



            #line 53 "..\..\MasterPage.cshtml"
            Write(RenderBody());


            #line default
            #line hidden
            WriteLiteral("\r\n            \r\n            <footer id=\"Footer\">\r\n                ");



            #line 56 "..\..\MasterPage.cshtml"
            Write(RenderPartial <PoweredBy>());


            #line default
            #line hidden
            WriteLiteral("\r\n                Server date is ");



            #line 57 "..\..\MasterPage.cshtml"
            Write(now.ToString("D", CultureInfo.InvariantCulture));


            #line default
            #line hidden
            WriteLiteral(".\r\n                Server time is ");



            #line 58 "..\..\MasterPage.cshtml"
            Write(now.ToString("T", CultureInfo.InvariantCulture));


            #line default
            #line hidden
            WriteLiteral(".\r\n                All dates and times displayed are in the\r\n                ");



            #line 60 "..\..\MasterPage.cshtml"
            Write(tz.IsDaylightSavingTime(now) ? tz.DaylightName : tz.StandardName);


            #line default
            #line hidden
            WriteLiteral(" zone.\r\n                ");



            #line 61 "..\..\MasterPage.cshtml"
            Write(Footnote);


            #line default
            #line hidden
            WriteLiteral("\r\n            </footer>\r\n        </div>\r\n    </body>\r\n</html>\r\n");
        }
Exemple #5
0
        public override void Execute()
        {
            WriteLiteral("\r\n");



            WriteLiteral("\r\n");



            #line 12 "..\..\MasterPage.cshtml"

            var basePageName = Request.ServerVariables["URL"];

            var now = DateTime.Now;
            var tz  = TimeZone.CurrentTimeZone;

            var about = PoweredBy.GetAbout(Context.Cache, (version, fileVersion, product, copyright) => new
            {
                Version = version != null
                  ? version.ToString()
                  : fileVersion != null
                  ? fileVersion.ToString()
                  : "?.?.?.?",
                Product   = Mask.EmptyString(product, "(product)"),
                Copyright = copyright,
            });

            var speedBarItems = (SpeedBarItems ?? Enumerable.Empty <SpeedBar.FormattedItem>()).ToArray();



            #line default
            #line hidden
            WriteLiteral("<!DOCTYPE html>\r\n<html>\r\n    <head>\r\n");



            #line 34 "..\..\MasterPage.cshtml"
            if (!string.IsNullOrEmpty(Title))
            {
            #line default
            #line hidden
                WriteLiteral("            <title>");



            #line 36 "..\..\MasterPage.cshtml"
                Write(Title);


            #line default
            #line hidden
                WriteLiteral("</title>\r\n");



            #line 37 "..\..\MasterPage.cshtml"
            }


            #line default
            #line hidden


            #line 38 "..\..\MasterPage.cshtml"



            #line default
            #line hidden
            WriteLiteral(@"        <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
        <!--[if lt IE 9]>
          <script src=""http://html5shim.googlecode.com/svn/trunk/html5.js""></script>
        <![endif]-->
        <link rel=""stylesheet"" type=""text/css"" href=""");



            #line 43 "..\..\MasterPage.cshtml"
            Write(basePageName);


            #line default
            #line hidden
            WriteLiteral("/stylesheet?h=");



            #line 43 "..\..\MasterPage.cshtml"
            Write(Uri.EscapeDataString(StyleSheetHelper.StyleSheetHash));


            #line default
            #line hidden
            WriteLiteral("\" />\r\n        <style type=\"text/css\">\r\n          body {\r\n            padding-top:" +
                         " 60px;\r\n          }\r\n        </style>\r\n    </head>\r\n    <body>\r\n");



            #line 51 "..\..\MasterPage.cshtml"
            if (speedBarItems.Any())
            {
            #line default
            #line hidden
                WriteLiteral(@"            <div id=""topnavbar"" class=""navbar navbar-fixed-top"">
                <div class=""navbar-inner"">
                    <div class=""container"">
                        <a class=""brand"" href=""http://elmah.googlecode.com/"">ELMAH</a>
                        ");



            #line 57 "..\..\MasterPage.cshtml"
                Write(SpeedBar.Render(Request.Browser, speedBarItems));


            #line default
            #line hidden
                WriteLiteral("\r\n                    </div>\r\n                </div>\r\n            </div>\r\n");



            #line 61 "..\..\MasterPage.cshtml"
            }


            #line default
            #line hidden
            WriteLiteral("        <div class=\"container-fluid\">\r\n            \r\n            ");



            #line 64 "..\..\MasterPage.cshtml"
            Write(RenderBody());


            #line default
            #line hidden
            WriteLiteral("\r\n            \r\n            <footer id=\"Footer\">\r\n                <span>Powered b" +
                         "y <a href=\"http://elmah.googlecode.com/\">");



            #line 67 "..\..\MasterPage.cshtml"
            Write(about.Product);


            #line default
            #line hidden
            WriteLiteral("</a>, \r\n                    version ");



            #line 68 "..\..\MasterPage.cshtml"
            Write(about.Version);


            #line default
            #line hidden
            WriteLiteral(".\r\n                    ");



            #line 69 "..\..\MasterPage.cshtml"
            Write(about.Copyright);


            #line default
            #line hidden
            WriteLiteral(" \r\n                    Licensed under <a href=\"http://www.apache.org/licenses/LIC" +
                         "ENSE-2.0\">Apache License, Version 2.0</a>. \r\n                </span>\r\n          " +
                         "      Server date is ");



            #line 72 "..\..\MasterPage.cshtml"
            Write(now.ToString("D", CultureInfo.InvariantCulture));


            #line default
            #line hidden
            WriteLiteral(". \r\n                Server time is ");



            #line 73 "..\..\MasterPage.cshtml"
            Write(now.ToString("T", CultureInfo.InvariantCulture));


            #line default
            #line hidden
            WriteLiteral(". \r\n                All dates and times displayed are in the \r\n                ");



            #line 75 "..\..\MasterPage.cshtml"
            Write(tz.IsDaylightSavingTime(now) ? tz.DaylightName : tz.StandardName);


            #line default
            #line hidden
            WriteLiteral(" zone. \r\n                ");



            #line 76 "..\..\MasterPage.cshtml"
            Write(Footnote);


            #line default
            #line hidden
            WriteLiteral("\r\n            </footer>\r\n        </div>\r\n    </body>\r\n</html>\r\n");
        }