Remove ErrorPageOptions properties except SourceCodeLineCount

- Removed all properties except `SourceCodeLineCount`
- Updated ErroPageMiddleware (including some minor code-style changes)
- Updated CompilationErrorPage.cshtml and ErrorPage.cshtml
- Added `run` command to PageGenerator project.json to execute from command line
- Include cookies on error page
- Removed showSource parameter
- Remove unused exception parameter
This commit is contained in:
Henk Mollema 2015-06-11 14:44:58 +02:00 committed by Chris R
parent ccdedc704d
commit 0da9e2bec5
10 changed files with 953 additions and 1173 deletions

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.22530.0 VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{509A6F36-AD80-4A18-B5B1-717D38DFF29D}"
EndProject EndProject

View File

@ -16,7 +16,7 @@ namespace StatusCodePagesSample
{ {
public void Configure(IApplicationBuilder app) 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(); // 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")); // app.UseStatusCodePages(context => context.HttpContext.Response.SendAsync("Handler, status code: " + context.HttpContext.Response.StatusCode, "text/plain"));

View File

@ -12,8 +12,8 @@ using System.Threading.Tasks;
using Microsoft.AspNet.Builder; using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Views; using Microsoft.AspNet.Diagnostics.Views;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Microsoft.Framework.Runtime;
using Microsoft.Framework.Internal; using Microsoft.Framework.Internal;
using Microsoft.Framework.Runtime;
namespace Microsoft.AspNet.Diagnostics namespace Microsoft.AspNet.Diagnostics
{ {
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Diagnostics
{ {
private readonly RequestDelegate _next; private readonly RequestDelegate _next;
private readonly ErrorPageOptions _options; private readonly ErrorPageOptions _options;
private static bool IsMono = Type.GetType("Mono.Runtime") != null; private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ErrorPageMiddleware"/> class /// Initializes a new instance of the <see cref="ErrorPageMiddleware"/> class
@ -70,17 +70,16 @@ namespace Microsoft.AspNet.Diagnostics
var compilationException = ex as ICompilationException; var compilationException = ex as ICompilationException;
if (compilationException != null) if (compilationException != null)
{ {
return DisplayCompilationException(context, ex, compilationException); return DisplayCompilationException(context, compilationException);
} }
return DisplayRuntimeException(context, ex); return DisplayRuntimeException(context, ex);
} }
private Task DisplayCompilationException(HttpContext context, private Task DisplayCompilationException(HttpContext context,
Exception ex,
ICompilationException compilationException) ICompilationException compilationException)
{ {
var model = new CompilationErrorPageModel() var model = new CompilationErrorPageModel
{ {
Options = _options, Options = _options,
}; };
@ -104,11 +103,8 @@ namespace Microsoft.AspNet.Diagnostics
Function = string.Empty Function = string.Empty
}; };
if (_options.ShowSourceCode)
{
ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine); ReadFrameContent(frame, fileContent, item.StartLine, item.EndLine);
frame.ErrorDetails = item.Message; frame.ErrorDetails = item.Message;
}
stackFrames.Add(frame); stackFrames.Add(frame);
} }
@ -128,62 +124,49 @@ namespace Microsoft.AspNet.Diagnostics
{ {
var request = context.Request; var request = context.Request;
ErrorPageModel model = new ErrorPageModel() var model = new ErrorPageModel
{ {
Options = _options, Options = _options,
ErrorDetails = GetErrorDetails(ex).Reverse(),
Query = request.Query,
Cookies = request.Cookies,
Headers = request.Headers
}; };
if (_options.ShowExceptionDetails) /* TODO:
{
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)
{
model.Environment = context; model.Environment = context;
}*/ */
var errorPage = new ErrorPage(model); var errorPage = new ErrorPage(model);
return errorPage.ExecuteAsync(context); return errorPage.ExecuteAsync(context);
} }
private IEnumerable<ErrorDetails> GetErrorDetails(Exception ex, bool showSource) private IEnumerable<ErrorDetails> 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 yield return new ErrorDetails
{ {
Error = scan, Error = scan,
StackFrames = StackFrames(scan, showSource) StackFrames = StackFrames(scan)
}; };
} }
} }
private IEnumerable<StackFrame> StackFrames(Exception ex, bool showSource) private IEnumerable<StackFrame> StackFrames(Exception ex)
{ {
var stackTrace = ex.StackTrace; var stackTrace = ex.StackTrace;
if (!string.IsNullOrEmpty(stackTrace)) if (!string.IsNullOrEmpty(stackTrace))
{ {
var heap = new Chunk { Text = stackTrace + Environment.NewLine, End = stackTrace.Length + Environment.NewLine.Length }; 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 "); line.Advance(" at ");
string function = line.Advance(" in ").ToString(); string function = line.Advance(" in ").ToString();
@ -198,16 +181,16 @@ namespace Microsoft.AspNet.Diagnostics
int lineNumber = line.ToInt32(); int lineNumber = line.ToInt32();
return string.IsNullOrEmpty(file) return string.IsNullOrEmpty(file)
? LoadFrame(string.IsNullOrEmpty(function) ? line.ToString() : function, string.Empty, 0, showSource) ? LoadFrame(string.IsNullOrEmpty(function) ? line.ToString() : function, string.Empty, 0)
: LoadFrame(function, file, lineNumber, showSource); : 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 }; var frame = new StackFrame { Function = function, File = file, Line = lineNumber };
if (showSource && File.Exists(file)) if (File.Exists(file))
{ {
IEnumerable<string> code = File.ReadLines(file); var code = File.ReadLines(file);
ReadFrameContent(frame, code, lineNumber, lineNumber); ReadFrameContent(frame, code, lineNumber, lineNumber);
} }
return frame; return frame;
@ -230,10 +213,7 @@ namespace Microsoft.AspNet.Diagnostics
public int Start { get; set; } public int Start { get; set; }
public int End { get; set; } public int End { get; set; }
public bool HasValue public bool HasValue => Text != null;
{
get { return Text != null; }
}
public Chunk Advance(string delimiter) public Chunk Advance(string delimiter)
{ {
@ -256,7 +236,7 @@ namespace Microsoft.AspNet.Diagnostics
public int ToInt32() public int ToInt32()
{ {
int value; int value;
return HasValue && Int32.TryParse( return HasValue && int.TryParse(
Text.Substring(Start, End - Start), Text.Substring(Start, End - Start),
NumberStyles.Integer, NumberStyles.Integer,
CultureInfo.InvariantCulture, CultureInfo.InvariantCulture,

View File

@ -17,54 +17,11 @@ namespace Microsoft.AspNet.Diagnostics
SourceCodeLineCount = 6; SourceCodeLineCount = 6;
} }
/// <summary>
/// Returns a new instance of ErrorPageOptions with all visibility options enabled by default.
/// </summary>
public static ErrorPageOptions ShowAll => new ErrorPageOptions
{
ShowExceptionDetails = true,
ShowSourceCode = true,
ShowQuery = true,
ShowCookies = true,
ShowHeaders = true,
ShowEnvironment = true,
};
/// <summary>
/// Enables the display of exception types, messages, and stack traces.
/// </summary>
public bool ShowExceptionDetails { get; set; }
/// <summary>
/// Enabled the display of local source code around exception stack frames.
/// </summary>
public bool ShowSourceCode { get; set; }
/// <summary> /// <summary>
/// Determines how many lines of code to include before and after the line of code /// 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. /// source code referenced by the exception stack trace is present on the server.
/// </summary> /// </summary>
public int SourceCodeLineCount { get; set; } public int SourceCodeLineCount { get; set; }
/// <summary>
/// Enables the enumeration of any parsed query values.
/// </summary>
public bool ShowQuery { get; set; }
/// <summary>
/// Enables the enumeration of any parsed request cookies.
/// </summary>
public bool ShowCookies { get; set; }
/// <summary>
/// Enables the enumeration of the request headers.
/// </summary>
public bool ShowHeaders { get; set; }
/// <summary>
/// Enables the enumeration of the OWIN environment values.
/// </summary>
public bool ShowEnvironment { get; set; }
} }
} }

View File

@ -79,29 +79,6 @@ using Views
#line hidden #line hidden
#line 26 "CompilationErrorPage.cshtml" #line 26 "CompilationErrorPage.cshtml"
if (!Model.Options.ShowExceptionDetails)
{
#line default
#line hidden
WriteLiteral(" <h2>");
#line 28 "CompilationErrorPage.cshtml"
Write(Resources.ErrorPageHtml_EnableShowExceptions);
#line default
#line hidden
WriteLiteral("</h2>\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) foreach (var errorDetail in Model.ErrorDetails)
{ {
@ -109,26 +86,26 @@ using Views
#line hidden #line hidden
WriteLiteral(" <div id=\"stackpage\" class=\"page\">\r\n"); WriteLiteral(" <div id=\"stackpage\" class=\"page\">\r\n");
#line 35 "CompilationErrorPage.cshtml" #line 29 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 35 "CompilationErrorPage.cshtml" #line 29 "CompilationErrorPage.cshtml"
int tabIndex = 6; int tabIndex = 6;
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 36 "CompilationErrorPage.cshtml" #line 30 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 36 "CompilationErrorPage.cshtml" #line 30 "CompilationErrorPage.cshtml"
var fileName = errorDetail.StackFrames.FirstOrDefault()?.File; var fileName = errorDetail.StackFrames.FirstOrDefault()?.File;
if (!string.IsNullOrEmpty(fileName)) if (!string.IsNullOrEmpty(fileName))
@ -138,13 +115,13 @@ using Views
#line hidden #line hidden
WriteLiteral(" <div class=\"titleerror\">"); WriteLiteral(" <div class=\"titleerror\">");
#line 40 "CompilationErrorPage.cshtml" #line 34 "CompilationErrorPage.cshtml"
Write(fileName); Write(fileName);
#line default #line default
#line hidden #line hidden
WriteLiteral("</div>\r\n"); WriteLiteral("</div>\r\n");
#line 41 "CompilationErrorPage.cshtml" #line 35 "CompilationErrorPage.cshtml"
} }
@ -152,13 +129,13 @@ using Views
#line hidden #line hidden
WriteLiteral("\r\n <br />\r\n <ul>\r\n"); WriteLiteral("\r\n <br />\r\n <ul>\r\n");
#line 45 "CompilationErrorPage.cshtml" #line 39 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 45 "CompilationErrorPage.cshtml" #line 39 "CompilationErrorPage.cshtml"
foreach (var frame in errorDetail.StackFrames) foreach (var frame in errorDetail.StackFrames)
{ {
@ -166,29 +143,29 @@ using Views
#line hidden #line hidden
WriteLiteral(" <li class=\"frame\""); WriteLiteral(" <li class=\"frame\"");
WriteAttribute("tabindex", Tuple.Create(" tabindex=\"", 1496), Tuple.Create("\"", 1516), WriteAttribute("tabindex", Tuple.Create(" tabindex=\"", 1231), Tuple.Create("\"", 1251),
Tuple.Create(Tuple.Create("", 1507), Tuple.Create<System.Object, System.Int32>(tabIndex, 1507), false)); Tuple.Create(Tuple.Create("", 1242), Tuple.Create<System.Object, System.Int32>(tabIndex, 1242), false));
WriteLiteral(">\r\n"); WriteLiteral(">\r\n");
#line 48 "CompilationErrorPage.cshtml" #line 42 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 48 "CompilationErrorPage.cshtml" #line 42 "CompilationErrorPage.cshtml"
tabIndex++; tabIndex++;
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 49 "CompilationErrorPage.cshtml" #line 43 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 49 "CompilationErrorPage.cshtml" #line 43 "CompilationErrorPage.cshtml"
if (!string.IsNullOrEmpty(frame.ErrorDetails)) if (!string.IsNullOrEmpty(frame.ErrorDetails))
{ {
@ -196,26 +173,26 @@ using Views
#line hidden #line hidden
WriteLiteral(" <h3>"); WriteLiteral(" <h3>");
#line 51 "CompilationErrorPage.cshtml" #line 45 "CompilationErrorPage.cshtml"
Write(frame.ErrorDetails); Write(frame.ErrorDetails);
#line default #line default
#line hidden #line hidden
WriteLiteral("</h3>\r\n"); WriteLiteral("</h3>\r\n");
#line 52 "CompilationErrorPage.cshtml" #line 46 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral("\r\n"); WriteLiteral("\r\n");
#line 54 "CompilationErrorPage.cshtml" #line 48 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 54 "CompilationErrorPage.cshtml" #line 48 "CompilationErrorPage.cshtml"
if (frame.Line != 0 && frame.ContextCode.Any()) if (frame.Line != 0 && frame.ContextCode.Any())
{ {
@ -223,13 +200,13 @@ using Views
#line hidden #line hidden
WriteLiteral(" <div class=\"source\">\r\n"); WriteLiteral(" <div class=\"source\">\r\n");
#line 57 "CompilationErrorPage.cshtml" #line 51 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 57 "CompilationErrorPage.cshtml" #line 51 "CompilationErrorPage.cshtml"
if (frame.PreContextCode != null) if (frame.PreContextCode != null)
{ {
@ -237,16 +214,16 @@ using Views
#line hidden #line hidden
WriteLiteral(" <ol"); WriteLiteral(" <ol");
WriteAttribute("start", Tuple.Create(" start=\"", 2086), Tuple.Create("\"", 2115), WriteAttribute("start", Tuple.Create(" start=\"", 1777), Tuple.Create("\"", 1806),
Tuple.Create(Tuple.Create("", 2094), Tuple.Create<System.Object, System.Int32>(frame.PreContextLine, 2094), false)); Tuple.Create(Tuple.Create("", 1785), Tuple.Create<System.Object, System.Int32>(frame.PreContextLine, 1785), false));
WriteLiteral(" class=\"collapsible\">\r\n"); WriteLiteral(" class=\"collapsible\">\r\n");
#line 60 "CompilationErrorPage.cshtml" #line 54 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 60 "CompilationErrorPage.cshtml" #line 54 "CompilationErrorPage.cshtml"
foreach (var line in frame.PreContextCode) foreach (var line in frame.PreContextCode)
{ {
@ -254,36 +231,36 @@ using Views
#line hidden #line hidden
WriteLiteral(" <li><span>"); WriteLiteral(" <li><span>");
#line 62 "CompilationErrorPage.cshtml" #line 56 "CompilationErrorPage.cshtml"
Write(line); Write(line);
#line default #line default
#line hidden #line hidden
WriteLiteral("</span></li>\r\n"); WriteLiteral("</span></li>\r\n");
#line 63 "CompilationErrorPage.cshtml" #line 57 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </ol>\r\n"); WriteLiteral(" </ol>\r\n");
#line 65 "CompilationErrorPage.cshtml" #line 59 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" <ol"); WriteLiteral(" <ol");
WriteAttribute("start", Tuple.Create(" start=\"", 2524), Tuple.Create("\"", 2543), WriteAttribute("start", Tuple.Create(" start=\"", 2187), Tuple.Create("\"", 2206),
Tuple.Create(Tuple.Create("", 2532), Tuple.Create<System.Object, System.Int32>(frame.Line, 2532), false)); Tuple.Create(Tuple.Create("", 2195), Tuple.Create<System.Object, System.Int32>(frame.Line, 2195), false));
WriteLiteral(" class=\"highlight\">\r\n"); WriteLiteral(" class=\"highlight\">\r\n");
#line 67 "CompilationErrorPage.cshtml" #line 61 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 67 "CompilationErrorPage.cshtml" #line 61 "CompilationErrorPage.cshtml"
foreach (var line in frame.ContextCode) foreach (var line in frame.ContextCode)
{ {
@ -291,26 +268,26 @@ using Views
#line hidden #line hidden
WriteLiteral(" <li><span>"); WriteLiteral(" <li><span>");
#line 69 "CompilationErrorPage.cshtml" #line 63 "CompilationErrorPage.cshtml"
Write(line); Write(line);
#line default #line default
#line hidden #line hidden
WriteLiteral("</span></li>\r\n"); WriteLiteral("</span></li>\r\n");
#line 70 "CompilationErrorPage.cshtml" #line 64 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </ol>\r\n"); WriteLiteral(" </ol>\r\n");
#line 72 "CompilationErrorPage.cshtml" #line 66 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 72 "CompilationErrorPage.cshtml" #line 66 "CompilationErrorPage.cshtml"
if (frame.PostContextCode != null) if (frame.PostContextCode != null)
{ {
@ -318,16 +295,16 @@ using Views
#line hidden #line hidden
WriteLiteral(" <ol"); WriteLiteral(" <ol");
WriteAttribute("start", Tuple.Create(" start=\'", 3004), Tuple.Create("\'", 3029), WriteAttribute("start", Tuple.Create(" start=\'", 2635), Tuple.Create("\'", 2660),
Tuple.Create(Tuple.Create("", 3012), Tuple.Create<System.Object, System.Int32>(frame.Line + 1, 3012), false)); Tuple.Create(Tuple.Create("", 2643), Tuple.Create<System.Object, System.Int32>(frame.Line + 1, 2643), false));
WriteLiteral(" class=\"collapsible\">\r\n"); WriteLiteral(" class=\"collapsible\">\r\n");
#line 75 "CompilationErrorPage.cshtml" #line 69 "CompilationErrorPage.cshtml"
#line default #line default
#line hidden #line hidden
#line 75 "CompilationErrorPage.cshtml" #line 69 "CompilationErrorPage.cshtml"
foreach (var line in frame.PostContextCode) foreach (var line in frame.PostContextCode)
{ {
@ -335,42 +312,41 @@ using Views
#line hidden #line hidden
WriteLiteral(" <li><span>"); WriteLiteral(" <li><span>");
#line 77 "CompilationErrorPage.cshtml" #line 71 "CompilationErrorPage.cshtml"
Write(line); Write(line);
#line default #line default
#line hidden #line hidden
WriteLiteral("</span></li>\r\n"); WriteLiteral("</span></li>\r\n");
#line 78 "CompilationErrorPage.cshtml" #line 72 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </ol>\r\n"); WriteLiteral(" </ol>\r\n");
#line 80 "CompilationErrorPage.cshtml" #line 74 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </div>\r\n"); WriteLiteral(" </div>\r\n");
#line 82 "CompilationErrorPage.cshtml" #line 76 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </li>\r\n"); WriteLiteral(" </li>\r\n");
#line 84 "CompilationErrorPage.cshtml" #line 78 "CompilationErrorPage.cshtml"
} }
#line default #line default
#line hidden #line hidden
WriteLiteral(" </ul>\r\n <br />\r\n </div>\r\n"); WriteLiteral(" </ul>\r\n <br />\r\n </div>\r\n");
#line 88 "CompilationErrorPage.cshtml" #line 82 "CompilationErrorPage.cshtml"
}
} }
#line default #line default

View File

@ -23,13 +23,7 @@
</head> </head>
<body> <body>
<h1>@Resources.ErrorPageHtml_CompilationException</h1> <h1>@Resources.ErrorPageHtml_CompilationException</h1>
@if (!Model.Options.ShowExceptionDetails) @foreach (var errorDetail in Model.ErrorDetails)
{
<h2>@Resources.ErrorPageHtml_EnableShowExceptions</h2>
}
@if (Model.Options.ShowExceptionDetails)
{
foreach (var errorDetail in Model.ErrorDetails)
{ {
<div id="stackpage" class="page"> <div id="stackpage" class="page">
@{ int tabIndex = 6; } @{ int tabIndex = 6; }
@ -86,7 +80,6 @@
<br /> <br />
</div> </div>
} }
}
<script> <script>
//<!-- //<!--
<%$ include: ErrorPage.js %> <%$ include: ErrorPage.js %>

File diff suppressed because one or more lines are too long

View File

@ -30,9 +30,7 @@
</head> </head>
<body> <body>
<h1>@Resources.ErrorPageHtml_UnhandledException</h1> <h1>@Resources.ErrorPageHtml_UnhandledException</h1>
@if (Model.Options.ShowExceptionDetails) @foreach (var errorDetail in Model.ErrorDetails)
{
foreach (var errorDetail in Model.ErrorDetails)
{ {
<div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div> <div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div>
@{ @{
@ -60,45 +58,24 @@
<p class="location">@Resources.ErrorPageHtml_UnknownLocation</p> <p class="location">@Resources.ErrorPageHtml_UnknownLocation</p>
} }
} }
}
else
{
<h2>@Resources.ErrorPageHtml_EnableShowExceptions</h2>
}
<ul id="header"> <ul id="header">
@if (Model.Options.ShowExceptionDetails)
{
<li id="stack" tabindex="1" class="selected"> <li id="stack" tabindex="1" class="selected">
@Resources.ErrorPageHtml_StackButton @Resources.ErrorPageHtml_StackButton
</li> </li>
}
@if (Model.Options.ShowQuery)
{
<li id="query" tabindex="2"> <li id="query" tabindex="2">
@Resources.ErrorPageHtml_QueryButton @Resources.ErrorPageHtml_QueryButton
</li> </li>
}
@if (Model.Options.ShowCookies)
{
<li id="cookies" tabindex="3"> <li id="cookies" tabindex="3">
@Resources.ErrorPageHtml_CookiesButton @Resources.ErrorPageHtml_CookiesButton
</li> </li>
}
@if (Model.Options.ShowHeaders)
{
<li id="headers" tabindex="4"> <li id="headers" tabindex="4">
@Resources.ErrorPageHtml_HeadersButton @Resources.ErrorPageHtml_HeadersButton
</li> </li>
}
@if (Model.Options.ShowEnvironment)
{
<li id="environment" tabindex="5"> <li id="environment" tabindex="5">
@Resources.ErrorPageHtml_EnvironmentButton @Resources.ErrorPageHtml_EnvironmentButton
</li> </li>
}
</ul> </ul>
@if (Model.Options.ShowExceptionDetails)
{
<div id="stackpage" class="page"> <div id="stackpage" class="page">
<ul> <ul>
@{ int tabIndex = 6; } @{ int tabIndex = 6; }
@ -158,9 +135,7 @@
} }
</ul> </ul>
</div> </div>
}
@if (Model.Options.ShowQuery)
{
<div id="querypage" class="page"> <div id="querypage" class="page">
@if (Model.Query.Any()) @if (Model.Query.Any())
{ {
@ -190,10 +165,7 @@
<p>@Resources.ErrorPageHtml_NoQueryStringData</p> <p>@Resources.ErrorPageHtml_NoQueryStringData</p>
} }
</div> </div>
}
@if (Model.Options.ShowCookies)
{
/* TODO:
<div id="cookiespage" class="page"> <div id="cookiespage" class="page">
@if (Model.Cookies.Any()) @if (Model.Cookies.Any())
{ {
@ -220,10 +192,7 @@
<p>@Resources.ErrorPageHtml_NoCookieData</p> <p>@Resources.ErrorPageHtml_NoCookieData</p>
} }
</div> </div>
*/
} }
@if (Model.Options.ShowHeaders)
{
<div id="headerspage" class="page"> <div id="headerspage" class="page">
@if (Model.Headers.Any()) @if (Model.Headers.Any())
{ {
@ -253,9 +222,8 @@
<p>@Resources.ErrorPageHtml_NoHeaderData</p> <p>@Resources.ErrorPageHtml_NoHeaderData</p>
} }
</div> </div>
}
@if (Model.Options.ShowEnvironment) @{
{
/* TODO: /* TODO:
<div id="environmentpage" class="page"> <div id="environmentpage" class="page">
<table> <table>

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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 System.Collections.Generic;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
@ -19,28 +18,28 @@ namespace Microsoft.AspNet.Diagnostics.Views
public ErrorPageOptions Options { get; set; } public ErrorPageOptions Options { get; set; }
/// <summary> /// <summary>
/// Detailed information about each exception in the stack /// Detailed information about each exception in the stack.
/// </summary> /// </summary>
public IEnumerable<ErrorDetails> ErrorDetails { get; set; } public IEnumerable<ErrorDetails> ErrorDetails { get; set; }
/// <summary> /// <summary>
/// Parsed query data /// Parsed query data.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")]
public IReadableStringCollection Query { get; set; } public IReadableStringCollection Query { get; set; }
/* TODO:
/// <summary> /// <summary>
/// Request cookies /// Request cookies.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")]
public RequestCookieCollection Cookies { get; set; } public IReadableStringCollection Cookies { get; set; }
*/
/// <summary> /// <summary>
/// Request headers /// Request headers.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Model class contains collection")]
public IDictionary<string, string[]> Headers { get; set; } public IDictionary<string, string[]> Headers { get; set; }
/* TODO: /* TODO:
/// <summary> /// <summary>
/// The request environment /// The request environment

View File

@ -13,5 +13,9 @@
"System.Console": "4.0.0-beta-*" "System.Console": "4.0.0-beta-*"
} }
} }
},
"commands": {
"run" : "PageGenerator"
} }
} }