diff --git a/DiagnosticsPages.sln b/DiagnosticsPages.sln index 3997d1ed5c..f893c1dfb7 100644 --- a/DiagnosticsPages.sln +++ b/DiagnosticsPages.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22530.0 +VisualStudioVersion = 14.0.22823.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}" EndProject diff --git a/samples/StatusCodePagesSample/Startup.cs b/samples/StatusCodePagesSample/Startup.cs index d402dbae68..27610ca64e 100644 --- a/samples/StatusCodePagesSample/Startup.cs +++ b/samples/StatusCodePagesSample/Startup.cs @@ -16,7 +16,7 @@ namespace StatusCodePagesSample { public void Configure(IApplicationBuilder app) { - app.UseErrorPage(ErrorPageOptions.ShowAll); + app.UseErrorPage(); app.UseStatusCodePages(); // There is a default response but any of the following can be used to change the behavior. // app.UseStatusCodePages(context => context.HttpContext.Response.SendAsync("Handler, status code: " + context.HttpContext.Response.StatusCode, "text/plain")); diff --git a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs index af4fc68e4c..689090976a 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorPageMiddleware.cs @@ -12,8 +12,8 @@ using System.Threading.Tasks; using Microsoft.AspNet.Builder; using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Http; -using Microsoft.Framework.Runtime; using Microsoft.Framework.Internal; +using Microsoft.Framework.Runtime; namespace Microsoft.AspNet.Diagnostics { @@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Diagnostics { private readonly RequestDelegate _next; private readonly ErrorPageOptions _options; - private static bool IsMono = Type.GetType("Mono.Runtime") != null; + private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; /// /// Initializes a new instance of the class @@ -70,17 +70,16 @@ namespace Microsoft.AspNet.Diagnostics var compilationException = ex as ICompilationException; if (compilationException != null) { - return DisplayCompilationException(context, ex, compilationException); + return DisplayCompilationException(context, compilationException); } return DisplayRuntimeException(context, ex); } private Task DisplayCompilationException(HttpContext context, - Exception ex, ICompilationException compilationException) { - var model = new CompilationErrorPageModel() + var model = new CompilationErrorPageModel { Options = _options, }; @@ -93,7 +92,7 @@ namespace Microsoft.AspNet.Diagnostics StackFrames = stackFrames }; var fileContent = compilationFailure.SourceFileContent - .Split(new[] { Environment.NewLine }, StringSplitOptions.None); + .Split(new[] { Environment.NewLine }, StringSplitOptions.None); foreach (var item in compilationFailure.Messages) { @@ -104,11 +103,8 @@ namespace Microsoft.AspNet.Diagnostics Function = string.Empty }; - if (_options.ShowSourceCode) - { - ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine); - frame.ErrorDetails = item.Message; - } + ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine); + frame.ErrorDetails = item.Message; stackFrames.Add(frame); } @@ -128,62 +124,49 @@ namespace Microsoft.AspNet.Diagnostics { var request = context.Request; - ErrorPageModel model = new ErrorPageModel() + var model = new ErrorPageModel { Options = _options, + ErrorDetails = GetErrorDetails(ex).Reverse(), + Query = request.Query, + Cookies = request.Cookies, + Headers = request.Headers }; - - if (_options.ShowExceptionDetails) - { - model.ErrorDetails = GetErrorDetails(ex, _options.ShowSourceCode).Reverse(); - } - if (_options.ShowQuery) - { - model.Query = request.Query; - }/* TODO: - if (_options.ShowCookies) - { - model.Cookies = request.Cookies; - }*/ - if (_options.ShowHeaders) - { - model.Headers = request.Headers; - }/* TODO: - if (_options.ShowEnvironment) - { + + /* TODO: model.Environment = context; - }*/ + */ var errorPage = new ErrorPage(model); return errorPage.ExecuteAsync(context); } - private IEnumerable GetErrorDetails(Exception ex, bool showSource) + private IEnumerable GetErrorDetails(Exception ex) { - for (Exception scan = ex; scan != null; scan = scan.InnerException) + for (var scan = ex; scan != null; scan = scan.InnerException) { yield return new ErrorDetails { Error = scan, - StackFrames = StackFrames(scan, showSource) + StackFrames = StackFrames(scan) }; } } - private IEnumerable StackFrames(Exception ex, bool showSource) + private IEnumerable StackFrames(Exception ex) { var stackTrace = ex.StackTrace; if (!string.IsNullOrEmpty(stackTrace)) { var heap = new Chunk { Text = stackTrace + Environment.NewLine, End = stackTrace.Length + Environment.NewLine.Length }; - for (Chunk line = heap.Advance(Environment.NewLine); line.HasValue; line = heap.Advance(Environment.NewLine)) + for (var line = heap.Advance(Environment.NewLine); line.HasValue; line = heap.Advance(Environment.NewLine)) { - yield return StackFrame(line, showSource); + yield return StackFrame(line); } } } - private StackFrame StackFrame(Chunk line, bool showSource) + private StackFrame StackFrame(Chunk line) { line.Advance(" at "); string function = line.Advance(" in ").ToString(); @@ -198,16 +181,16 @@ namespace Microsoft.AspNet.Diagnostics int lineNumber = line.ToInt32(); return string.IsNullOrEmpty(file) - ? LoadFrame(string.IsNullOrEmpty(function) ? line.ToString() : function, string.Empty, 0, showSource) - : LoadFrame(function, file, lineNumber, showSource); + ? LoadFrame(string.IsNullOrEmpty(function) ? line.ToString() : function, string.Empty, 0) + : LoadFrame(function, file, lineNumber); } - private StackFrame LoadFrame(string function, string file, int lineNumber, bool showSource) + private StackFrame LoadFrame(string function, string file, int lineNumber) { var frame = new StackFrame { Function = function, File = file, Line = lineNumber }; - if (showSource && File.Exists(file)) + if (File.Exists(file)) { - IEnumerable code = File.ReadLines(file); + var code = File.ReadLines(file); ReadFrameContent(frame, code, lineNumber, lineNumber); } return frame; @@ -230,10 +213,7 @@ namespace Microsoft.AspNet.Diagnostics public int Start { get; set; } public int End { get; set; } - public bool HasValue - { - get { return Text != null; } - } + public bool HasValue => Text != null; public Chunk Advance(string delimiter) { @@ -256,7 +236,7 @@ namespace Microsoft.AspNet.Diagnostics public int ToInt32() { int value; - return HasValue && Int32.TryParse( + return HasValue && int.TryParse( Text.Substring(Start, End - Start), NumberStyles.Integer, CultureInfo.InvariantCulture, diff --git a/src/Microsoft.AspNet.Diagnostics/ErrorPageOptions.cs b/src/Microsoft.AspNet.Diagnostics/ErrorPageOptions.cs index 79afc26ede..6e1a05432a 100644 --- a/src/Microsoft.AspNet.Diagnostics/ErrorPageOptions.cs +++ b/src/Microsoft.AspNet.Diagnostics/ErrorPageOptions.cs @@ -17,54 +17,11 @@ namespace Microsoft.AspNet.Diagnostics SourceCodeLineCount = 6; } - /// - /// Returns a new instance of ErrorPageOptions with all visibility options enabled by default. - /// - public static ErrorPageOptions ShowAll => new ErrorPageOptions - { - ShowExceptionDetails = true, - ShowSourceCode = true, - ShowQuery = true, - ShowCookies = true, - ShowHeaders = true, - ShowEnvironment = true, - }; - - /// - /// Enables the display of exception types, messages, and stack traces. - /// - public bool ShowExceptionDetails { get; set; } - - /// - /// Enabled the display of local source code around exception stack frames. - /// - public bool ShowSourceCode { get; set; } - /// /// Determines how many lines of code to include before and after the line of code - /// present in an exception's stack frame. Only applies when symbols are available and + /// present in an exception's stack frame. Only applies when symbols are available and /// source code referenced by the exception stack trace is present on the server. /// public int SourceCodeLineCount { get; set; } - - /// - /// Enables the enumeration of any parsed query values. - /// - public bool ShowQuery { get; set; } - - /// - /// Enables the enumeration of any parsed request cookies. - /// - public bool ShowCookies { get; set; } - - /// - /// Enables the enumeration of the request headers. - /// - public bool ShowHeaders { get; set; } - - /// - /// Enables the enumeration of the OWIN environment values. - /// - public bool ShowEnvironment { get; set; } } } diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs index 5d2268e11a..2f9980a7aa 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cs @@ -79,298 +79,274 @@ using Views #line hidden #line 26 "CompilationErrorPage.cshtml" - if (!Model.Options.ShowExceptionDetails) + foreach (var errorDetail in Model.ErrorDetails) { #line default #line hidden - WriteLiteral("

"); -#line 28 "CompilationErrorPage.cshtml" - Write(Resources.ErrorPageHtml_EnableShowExceptions); - -#line default -#line hidden - WriteLiteral("

\r\n"); + WriteLiteral("
\r\n"); #line 29 "CompilationErrorPage.cshtml" - } + #line default #line hidden - WriteLiteral(" "); -#line 30 "CompilationErrorPage.cshtml" - if (Model.Options.ShowExceptionDetails) - { - foreach (var errorDetail in Model.ErrorDetails) - { - -#line default -#line hidden - - WriteLiteral("
\r\n"); -#line 35 "CompilationErrorPage.cshtml" - - -#line default -#line hidden - -#line 35 "CompilationErrorPage.cshtml" - int tabIndex = 6; +#line 29 "CompilationErrorPage.cshtml" + int tabIndex = 6; #line default #line hidden WriteLiteral("\r\n"); -#line 36 "CompilationErrorPage.cshtml" - +#line 30 "CompilationErrorPage.cshtml" + #line default #line hidden -#line 36 "CompilationErrorPage.cshtml" - - var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; - if (!string.IsNullOrEmpty(fileName)) - { - -#line default -#line hidden - - WriteLiteral("
"); -#line 40 "CompilationErrorPage.cshtml" - Write(fileName); - -#line default -#line hidden - WriteLiteral("
\r\n"); -#line 41 "CompilationErrorPage.cshtml" - } - - -#line default -#line hidden - - WriteLiteral("\r\n
\r\n
    \r\n"); -#line 45 "CompilationErrorPage.cshtml" - - -#line default -#line hidden - -#line 45 "CompilationErrorPage.cshtml" - foreach (var frame in errorDetail.StackFrames) +#line 30 "CompilationErrorPage.cshtml" + + var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; + if (!string.IsNullOrEmpty(fileName)) { #line default #line hidden - WriteLiteral("
  • (tabIndex, 1507), false)); - WriteLiteral(">\r\n"); -#line 48 "CompilationErrorPage.cshtml" - + WriteLiteral("
    "); +#line 34 "CompilationErrorPage.cshtml" + Write(fileName); + +#line default +#line hidden + WriteLiteral("
    \r\n"); +#line 35 "CompilationErrorPage.cshtml" + } + #line default #line hidden -#line 48 "CompilationErrorPage.cshtml" - tabIndex++; + WriteLiteral("\r\n
    \r\n
      \r\n"); +#line 39 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 39 "CompilationErrorPage.cshtml" + foreach (var frame in errorDetail.StackFrames) + { + +#line default +#line hidden + + WriteLiteral("
    • (tabIndex, 1242), false)); + WriteLiteral(">\r\n"); +#line 42 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 42 "CompilationErrorPage.cshtml" + tabIndex++; #line default #line hidden WriteLiteral("\r\n"); -#line 49 "CompilationErrorPage.cshtml" - +#line 43 "CompilationErrorPage.cshtml" + #line default #line hidden -#line 49 "CompilationErrorPage.cshtml" - if (!string.IsNullOrEmpty(frame.ErrorDetails)) - { +#line 43 "CompilationErrorPage.cshtml" + if (!string.IsNullOrEmpty(frame.ErrorDetails)) + { #line default #line hidden - WriteLiteral("

      "); -#line 51 "CompilationErrorPage.cshtml" - Write(frame.ErrorDetails); + WriteLiteral("

      "); +#line 45 "CompilationErrorPage.cshtml" + Write(frame.ErrorDetails); #line default #line hidden WriteLiteral("

      \r\n"); -#line 52 "CompilationErrorPage.cshtml" - } +#line 46 "CompilationErrorPage.cshtml" + } #line default #line hidden WriteLiteral("\r\n"); -#line 54 "CompilationErrorPage.cshtml" - +#line 48 "CompilationErrorPage.cshtml" + #line default #line hidden -#line 54 "CompilationErrorPage.cshtml" - if (frame.Line != 0 && frame.ContextCode.Any()) - { +#line 48 "CompilationErrorPage.cshtml" + if (frame.Line != 0 && frame.ContextCode.Any()) + { #line default #line hidden - WriteLiteral("
      \r\n"); -#line 57 "CompilationErrorPage.cshtml" - + WriteLiteral("
      \r\n"); +#line 51 "CompilationErrorPage.cshtml" + #line default #line hidden -#line 57 "CompilationErrorPage.cshtml" - if (frame.PreContextCode != null) - { - -#line default -#line hidden - - WriteLiteral(" (frame.PreContextLine, 2094), false)); - WriteLiteral(" class=\"collapsible\">\r\n"); -#line 60 "CompilationErrorPage.cshtml" - - -#line default -#line hidden - -#line 60 "CompilationErrorPage.cshtml" - foreach (var line in frame.PreContextCode) - { - -#line default -#line hidden - - WriteLiteral("
    • "); -#line 62 "CompilationErrorPage.cshtml" - Write(line); - -#line default -#line hidden - WriteLiteral("
    • \r\n"); -#line 63 "CompilationErrorPage.cshtml" - } - -#line default -#line hidden - - WriteLiteral(" \r\n"); -#line 65 "CompilationErrorPage.cshtml" - } +#line 51 "CompilationErrorPage.cshtml" + if (frame.PreContextCode != null) + { #line default #line hidden WriteLiteral(" (frame.Line, 2532), false)); - WriteLiteral(" class=\"highlight\">\r\n"); -#line 67 "CompilationErrorPage.cshtml" + WriteAttribute("start", Tuple.Create(" start=\"", 1777), Tuple.Create("\"", 1806), + Tuple.Create(Tuple.Create("", 1785), Tuple.Create(frame.PreContextLine, 1785), false)); + WriteLiteral(" class=\"collapsible\">\r\n"); +#line 54 "CompilationErrorPage.cshtml" #line default #line hidden -#line 67 "CompilationErrorPage.cshtml" - foreach (var line in frame.ContextCode) +#line 54 "CompilationErrorPage.cshtml" + foreach (var line in frame.PreContextCode) { #line default #line hidden WriteLiteral("
    • "); -#line 69 "CompilationErrorPage.cshtml" +#line 56 "CompilationErrorPage.cshtml" Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); -#line 70 "CompilationErrorPage.cshtml" +#line 57 "CompilationErrorPage.cshtml" } #line default #line hidden WriteLiteral(" \r\n"); -#line 72 "CompilationErrorPage.cshtml" +#line 59 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral(" (frame.Line, 2195), false)); + WriteLiteral(" class=\"highlight\">\r\n"); +#line 61 "CompilationErrorPage.cshtml" #line default #line hidden -#line 72 "CompilationErrorPage.cshtml" - if (frame.PostContextCode != null) +#line 61 "CompilationErrorPage.cshtml" + foreach (var line in frame.ContextCode) { #line default #line hidden - WriteLiteral(" (frame.Line + 1, 3012), false)); - WriteLiteral(" class=\"collapsible\">\r\n"); -#line 75 "CompilationErrorPage.cshtml" - - -#line default -#line hidden - -#line 75 "CompilationErrorPage.cshtml" - foreach (var line in frame.PostContextCode) - { - -#line default -#line hidden - - WriteLiteral("
    • "); -#line 77 "CompilationErrorPage.cshtml" - Write(line); + WriteLiteral("
    • "); +#line 63 "CompilationErrorPage.cshtml" + Write(line); #line default #line hidden WriteLiteral("
    • \r\n"); +#line 64 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral(" \r\n"); +#line 66 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 66 "CompilationErrorPage.cshtml" + if (frame.PostContextCode != null) + { + +#line default +#line hidden + + WriteLiteral(" (frame.Line + 1, 2643), false)); + WriteLiteral(" class=\"collapsible\">\r\n"); +#line 69 "CompilationErrorPage.cshtml" + + +#line default +#line hidden + +#line 69 "CompilationErrorPage.cshtml" + foreach (var line in frame.PostContextCode) + { + +#line default +#line hidden + + WriteLiteral("
    • "); +#line 71 "CompilationErrorPage.cshtml" + Write(line); + +#line default +#line hidden + WriteLiteral("
    • \r\n"); +#line 72 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral(" \r\n"); +#line 74 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral("
\r\n"); +#line 76 "CompilationErrorPage.cshtml" + } + +#line default +#line hidden + + WriteLiteral(" \r\n"); #line 78 "CompilationErrorPage.cshtml" - } + } #line default #line hidden - WriteLiteral(" \r\n"); -#line 80 "CompilationErrorPage.cshtml" - } - -#line default -#line hidden - - WriteLiteral("
\r\n"); + WriteLiteral(" \r\n
\r\n \r\n"); #line 82 "CompilationErrorPage.cshtml" - } - -#line default -#line hidden - - WriteLiteral(" \r\n"); -#line 84 "CompilationErrorPage.cshtml" - } - -#line default -#line hidden - - WriteLiteral(" \r\n
\r\n \r\n"); -#line 88 "CompilationErrorPage.cshtml" - } } #line default diff --git a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml index ff0db12777..476dc2ff11 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics/Views/CompilationErrorPage.cshtml @@ -23,69 +23,62 @@

@Resources.ErrorPageHtml_CompilationException

- @if (!Model.Options.ShowExceptionDetails) + @foreach (var errorDetail in Model.ErrorDetails) { -

@Resources.ErrorPageHtml_EnableShowExceptions

- } - @if (Model.Options.ShowExceptionDetails) - { - foreach (var errorDetail in Model.ErrorDetails) - { -
- @{ int tabIndex = 6; } - @{ - var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; - if (!string.IsNullOrEmpty(fileName)) - { -
@fileName
- } - } -
-
    - @foreach (var frame in errorDetail.StackFrames) +
    + @{ int tabIndex = 6; } + @{ + var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; + if (!string.IsNullOrEmpty(fileName)) { -
  • - @{ tabIndex++; } - @if (!string.IsNullOrEmpty(frame.ErrorDetails)) - { -

    @frame.ErrorDetails

    - } +
    @fileName
    + } + } +
    +
      + @foreach (var frame in errorDetail.StackFrames) + { +
    • + @{ tabIndex++; } + @if (!string.IsNullOrEmpty(frame.ErrorDetails)) + { +

      @frame.ErrorDetails

      + } - @if (frame.Line != 0 && frame.ContextCode.Any()) - { -
      - @if (frame.PreContextCode != null) - { -
        - @foreach (var line in frame.PreContextCode) - { -
      1. @line
      2. - } -
      - } -
        - @foreach (var line in frame.ContextCode) + @if (frame.Line != 0 && frame.ContextCode.Any()) + { +
        + @if (frame.PreContextCode != null) + { +
          + @foreach (var line in frame.PreContextCode) {
        1. @line
        2. }
        - @if (frame.PostContextCode != null) + } +
          + @foreach (var line in frame.ContextCode) { -
            - @foreach (var line in frame.PostContextCode) - { -
          1. @line
          2. - } -
          - } -
        - } - - } -
    -
    -
  • - } +
  • @line
  • + } + + @if (frame.PostContextCode != null) + { +
      + @foreach (var line in frame.PostContextCode) + { +
    1. @line
    2. + } +
    + } +
+ } + + } + +
+ } \r\n \r\n\r\n"); + WriteLiteral("\r\n \r\n \r\n\r\n"); } #pragma warning restore 1998 } diff --git a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml index eabeb0cdc8..463b41da0d 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml +++ b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPage.cshtml @@ -30,232 +30,200 @@

@Resources.ErrorPageHtml_UnhandledException

- @if (Model.Options.ShowExceptionDetails) + @foreach (var errorDetail in Model.ErrorDetails) { - foreach (var errorDetail in Model.ErrorDetails) - { -
@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }
- @{ - StackFrame firstFrame = null; - firstFrame = errorDetail.StackFrames.FirstOrDefault(); - if (firstFrame != null) - { - location = firstFrame.Function; - }/* TODO: TargetSite is not defined - else if (errorDetail.Error.TargetSite != null && errorDetail.Error.TargetSite.DeclaringType != null) - { - location = errorDetail.Error.TargetSite.DeclaringType.FullName + "." + errorDetail.Error.TargetSite.Name; - }*/ - } - if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File)) +
@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }
+ @{ + StackFrame firstFrame = null; + firstFrame = errorDetail.StackFrames.FirstOrDefault(); + if (firstFrame != null) { -

@location in @System.IO.Path.GetFileName(firstFrame.File), line @firstFrame.Line

- } - else if (!string.IsNullOrEmpty(location)) + location = firstFrame.Function; + }/* TODO: TargetSite is not defined + else if (errorDetail.Error.TargetSite != null && errorDetail.Error.TargetSite.DeclaringType != null) { -

@location

- } - else - { -

@Resources.ErrorPageHtml_UnknownLocation

- } + location = errorDetail.Error.TargetSite.DeclaringType.FullName + "." + errorDetail.Error.TargetSite.Name; + }*/ + } + if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File)) + { +

@location in @System.IO.Path.GetFileName(firstFrame.File), line @firstFrame.Line

+ } + else if (!string.IsNullOrEmpty(location)) + { +

@location

+ } + else + { +

@Resources.ErrorPageHtml_UnknownLocation

} - } - else - { -

@Resources.ErrorPageHtml_EnableShowExceptions

} - @if (Model.Options.ShowExceptionDetails) - { -
-
    - @{ int tabIndex = 6; } - @foreach (var errorDetail in Model.ErrorDetails) - { -
  • -

    @errorDetail.Error.GetType().Name: @errorDetail.Error.Message

    -
      - @foreach (var frame in errorDetail.StackFrames) - { -
    • - @{ tabIndex++; } - @if (string.IsNullOrEmpty(frame.File)) - { -

      @frame.Function

      - } - else - { -

      @frame.Function in @System.IO.Path.GetFileName(frame.File)

      - } + +
      +
        + @{ int tabIndex = 6; } + @foreach (var errorDetail in Model.ErrorDetails) + { +
      • +

        @errorDetail.Error.GetType().Name: @errorDetail.Error.Message

        +
          + @foreach (var frame in errorDetail.StackFrames) + { +
        • + @{ tabIndex++; } + @if (string.IsNullOrEmpty(frame.File)) + { +

          @frame.Function

          + } + else + { +

          @frame.Function in @System.IO.Path.GetFileName(frame.File)

          + } - @if (frame.Line != 0 && frame.ContextCode.Any()) - { -
          - @if (frame.PreContextCode != null) - { -
            - @foreach (var line in frame.PreContextCode) - { -
          1. @line
          2. - } -
          - } - -
            - @foreach (var line in frame.ContextCode) + @if (frame.Line != 0 && frame.ContextCode.Any()) + { +
            + @if (frame.PreContextCode != null) + { +
              + @foreach (var line in frame.PreContextCode) {
            1. @line
            2. }
            + } - @if (frame.PostContextCode != null) +
              + @foreach (var line in frame.ContextCode) { -
                - @foreach (var line in frame.PostContextCode) - { -
              1. @line
              2. - } -
              - } -
            - } - - } -
        -
      • - } -
      -
      - } - @if (Model.Options.ShowQuery) - { -
      - @if (Model.Query.Any()) - { - - - - - - - - - @foreach (var kv in Model.Query.OrderBy(kv => kv.Key)) - { - foreach (var v in kv.Value) - { - - - - - } - } - -
      @Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn
      @kv.Key@v
      +
    • @line
    • + } + + + @if (frame.PostContextCode != null) + { +
        + @foreach (var line in frame.PostContextCode) + { +
      1. @line
      2. + } +
      + } +
+ } + + } + + } - else - { -

@Resources.ErrorPageHtml_NoQueryStringData

- } - - } - @if (Model.Options.ShowCookies) - { - /* TODO: -
- @if (Model.Cookies.Any()) - { - - - - - - - - - @foreach (var kv in Model.Cookies.OrderBy(kv => kv.Key)) + + + +
+ @if (Model.Query.Any()) + { +
@Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn
+ + + + + + + + @foreach (var kv in Model.Query.OrderBy(kv => kv.Key)) + { + foreach (var v in kv.Value) { - + } - -
@Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn
@kv.Key@kv.Value@v
- } - else - { -

@Resources.ErrorPageHtml_NoCookieData

- } -
- */ - } - @if (Model.Options.ShowHeaders) - { -
- @if (Model.Headers.Any()) - { - - + } + +
+ } + else + { +

@Resources.ErrorPageHtml_NoQueryStringData

+ } +
+ +
+ @if (Model.Cookies.Any()) + { + + + + + + + + + @foreach (var kv in Model.Cookies.OrderBy(kv => kv.Key)) + { - - + + - - - @foreach (var kv in Model.Headers.OrderBy(kv => kv.Key)) - { - foreach (var v in kv.Value) - { - - - - - } - } - -
@Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn
@Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn@kv.Key@kv.Value
@kv.Key@v
- } - else - { -

@Resources.ErrorPageHtml_NoHeaderData

- } -
+ } + + + } + else + { +

@Resources.ErrorPageHtml_NoCookieData

+ } + } - @if (Model.Options.ShowEnvironment) - { +
+ @if (Model.Headers.Any()) + { + + + + + + + + + @foreach (var kv in Model.Headers.OrderBy(kv => kv.Key)) + { + foreach (var v in kv.Value) + { + + + + + } + } + +
@Resources.ErrorPageHtml_VariableColumn@Resources.ErrorPageHtml_ValueColumn
@kv.Key@v
+ } + else + { +

@Resources.ErrorPageHtml_NoHeaderData

+ } +
+ + @{ /* TODO:
diff --git a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPageModel.cs b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPageModel.cs index c31583b3b0..de93646abf 100644 --- a/src/Microsoft.AspNet.Diagnostics/Views/ErrorPageModel.cs +++ b/src/Microsoft.AspNet.Diagnostics/Views/ErrorPageModel.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Collections.Generic; using Microsoft.AspNet.Http; @@ -19,28 +18,28 @@ namespace Microsoft.AspNet.Diagnostics.Views public ErrorPageOptions Options { get; set; } /// - /// Detailed information about each exception in the stack + /// Detailed information about each exception in the stack. /// public IEnumerable ErrorDetails { get; set; } /// - /// Parsed query data + /// Parsed query data. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] public IReadableStringCollection Query { get; set; } - - /* TODO: + /// - /// Request cookies + /// Request cookies. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] - public RequestCookieCollection Cookies { get; set; } - */ + public IReadableStringCollection Cookies { get; set; } + /// - /// Request headers + /// Request headers. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] public IDictionary Headers { get; set; } + /* TODO: /// /// The request environment diff --git a/src/PageGenerator/project.json b/src/PageGenerator/project.json index c875781092..7f5d226d02 100644 --- a/src/PageGenerator/project.json +++ b/src/PageGenerator/project.json @@ -1,17 +1,21 @@ { - "version": "1.0.0-*", - "dependencies": { - "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", - "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", - "Microsoft.AspNet.Razor": "4.0.0-*" - }, + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Diagnostics.Elm": "1.0.0-*", + "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*", + "Microsoft.AspNet.Razor": "4.0.0-*" + }, - "frameworks": { - "dnx451": { }, - "dnxcore50": { - "dependencies": { - "System.Console": "4.0.0-beta-*" - } - } + "frameworks": { + "dnx451": { }, + "dnxcore50": { + "dependencies": { + "System.Console": "4.0.0-beta-*" + } } + }, + + "commands": { + "run" : "PageGenerator" + } }