Add routing information to DeveloperExceptionPage (#6320)
This commit is contained in:
parent
50996e3da1
commit
98cce23c67
|
|
@ -4,12 +4,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.Internal;
|
||||
using Microsoft.AspNetCore.Diagnostics.RazorViews;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
|
@ -192,6 +195,27 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
|
||||
private Task DisplayRuntimeException(HttpContext context, Exception ex)
|
||||
{
|
||||
var endpoint = context.Features.Get<IEndpointFeature>()?.Endpoint;
|
||||
|
||||
EndpointModel endpointModel = null;
|
||||
if (endpoint != null)
|
||||
{
|
||||
endpointModel = new EndpointModel();
|
||||
endpointModel.DisplayName = endpoint.DisplayName;
|
||||
|
||||
if (endpoint is RouteEndpoint routeEndpoint)
|
||||
{
|
||||
endpointModel.RoutePattern = routeEndpoint.RoutePattern.RawText;
|
||||
endpointModel.Order = routeEndpoint.Order;
|
||||
|
||||
var httpMethods = endpoint.Metadata.GetMetadata<IHttpMethodMetadata>()?.HttpMethods;
|
||||
if (httpMethods != null)
|
||||
{
|
||||
endpointModel.HttpMethods = string.Join(", ", httpMethods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var request = context.Request;
|
||||
|
||||
var model = new ErrorPageModel
|
||||
|
|
@ -200,7 +224,9 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
ErrorDetails = _exceptionDetailsProvider.GetDetails(ex),
|
||||
Query = request.Query,
|
||||
Cookies = request.Cookies,
|
||||
Headers = request.Headers
|
||||
Headers = request.Headers,
|
||||
RouteValues = request.RouteValues,
|
||||
Endpoint = endpointModel
|
||||
};
|
||||
|
||||
var errorPage = new ErrorPage(model);
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
namespace Microsoft.AspNetCore.Diagnostics.RazorViews
|
||||
{
|
||||
#line hidden
|
||||
using System.Threading.Tasks;
|
||||
#line 1 "CompilationErrorPage.cshtml"
|
||||
using System;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
using System.Threading.Tasks;
|
||||
#line 2 "CompilationErrorPage.cshtml"
|
||||
using System.Globalization;
|
||||
|
||||
|
|
@ -62,11 +62,6 @@ using Microsoft.AspNetCore.Diagnostics.RazorViews;
|
|||
background-color: #fff;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
/*font-family: 'Segoe UI',Tahoma,Arial,Helvetica,sans-serif;*/
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #44525e;
|
||||
margin: 15px 0 15px 0;
|
||||
|
|
@ -79,10 +74,12 @@ h2 {
|
|||
h3 {
|
||||
color: #363636;
|
||||
margin: 5px 5px 0 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Consolas, ""Courier New"", courier, monospace;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
body .titleerror {
|
||||
|
|
@ -112,10 +109,10 @@ body .location {
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
#h");
|
||||
WriteLiteral(@"eader .selected {
|
||||
#header .selected {
|
||||
background: #44c5f2;
|
||||
color: #fff;
|
||||
color: #fff");
|
||||
WriteLiteral(@";
|
||||
}
|
||||
|
||||
#stackpage ul {
|
||||
|
|
@ -169,10 +166,15 @@ body .location {
|
|||
color: #606060;
|
||||
}
|
||||
|
||||
#routingpage .subheader {
|
||||
padding: 5px;
|
||||
border-bottom: 1px #ddd solid;
|
||||
}
|
||||
|
||||
.page table {
|
||||
border-collapse: separate;
|
||||
bo");
|
||||
WriteLiteral(@"rder-spacing: 0;
|
||||
border-collapse");
|
||||
WriteLiteral(@": separate;
|
||||
border-spacing: 0;
|
||||
margin: 0 0 20px;
|
||||
}
|
||||
|
||||
|
|
@ -227,9 +229,9 @@ a {
|
|||
}
|
||||
|
||||
.rawExceptionStackTrace {
|
||||
font-size: 1.2em;
|
||||
");
|
||||
WriteLiteral(@"}
|
||||
");
|
||||
WriteLiteral(@"font-size: 1.2em;
|
||||
}
|
||||
|
||||
.rawExceptionBlock {
|
||||
border-top: 1px #ddd solid;
|
||||
|
|
@ -259,21 +261,20 @@ a {
|
|||
</head>
|
||||
<body>
|
||||
<h1>");
|
||||
#line 222 "CompilationErrorPage.cshtml"
|
||||
#line 224 "CompilationErrorPage.cshtml"
|
||||
Write(Resources.ErrorPageHtml_CompilationException);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h1>\r\n");
|
||||
#line 223 "CompilationErrorPage.cshtml"
|
||||
#line 225 "CompilationErrorPage.cshtml"
|
||||
|
||||
var exceptionDetailId = "";
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
#line 226 "CompilationErrorPage.cshtml"
|
||||
#line 228 "CompilationErrorPage.cshtml"
|
||||
for (var i = 0; i < Model.ErrorDetails.Count; i++)
|
||||
{
|
||||
var errorDetail = Model.ErrorDetails[i];
|
||||
|
|
@ -283,7 +284,7 @@ a {
|
|||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div id=\"stackpage\" class=\"page\">\r\n");
|
||||
#line 232 "CompilationErrorPage.cshtml"
|
||||
#line 234 "CompilationErrorPage.cshtml"
|
||||
|
||||
var stackFrameCount = 0;
|
||||
var frameId = "";
|
||||
|
|
@ -294,39 +295,38 @@ a {
|
|||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div class=\"titleerror\">");
|
||||
#line 238 "CompilationErrorPage.cshtml"
|
||||
#line 240 "CompilationErrorPage.cshtml"
|
||||
Write(fileName);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</div>\r\n");
|
||||
#line 239 "CompilationErrorPage.cshtml"
|
||||
#line 241 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
#line 241 "CompilationErrorPage.cshtml"
|
||||
#line 243 "CompilationErrorPage.cshtml"
|
||||
if (!string.IsNullOrEmpty(errorDetail.ErrorMessage))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div class=\"details\">");
|
||||
#line 243 "CompilationErrorPage.cshtml"
|
||||
#line 245 "CompilationErrorPage.cshtml"
|
||||
Write(errorDetail.ErrorMessage);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</div>\r\n");
|
||||
#line 244 "CompilationErrorPage.cshtml"
|
||||
#line 246 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <br />\r\n <ul>\r\n");
|
||||
#line 247 "CompilationErrorPage.cshtml"
|
||||
#line 249 "CompilationErrorPage.cshtml"
|
||||
foreach (var frame in errorDetail.StackFrames)
|
||||
{
|
||||
stackFrameCount++;
|
||||
|
|
@ -336,198 +336,198 @@ a {
|
|||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <li class=\"frame\"");
|
||||
BeginWriteAttribute("id", " id=\"", 5268, "\"", 5281, 1);
|
||||
#line 252 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 5273, frameId, 5273, 8, false);
|
||||
BeginWriteAttribute("id", " id=\"", 5287, "\"", 5300, 1);
|
||||
#line 254 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 5292, frameId, 5292, 8, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(">\r\n");
|
||||
#line 253 "CompilationErrorPage.cshtml"
|
||||
#line 255 "CompilationErrorPage.cshtml"
|
||||
if (!string.IsNullOrEmpty(frame.ErrorDetails))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <h3>");
|
||||
#line 255 "CompilationErrorPage.cshtml"
|
||||
#line 257 "CompilationErrorPage.cshtml"
|
||||
Write(frame.ErrorDetails);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h3>\r\n");
|
||||
#line 256 "CompilationErrorPage.cshtml"
|
||||
#line 258 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
#line 258 "CompilationErrorPage.cshtml"
|
||||
#line 260 "CompilationErrorPage.cshtml"
|
||||
if (frame.Line != 0 && frame.ContextCode.Any())
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <button class=\"expandCollapseButton\" data-frameId=\"");
|
||||
#line 260 "CompilationErrorPage.cshtml"
|
||||
#line 262 "CompilationErrorPage.cshtml"
|
||||
Write(frameId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\">+</button>\r\n <div class=\"source\">\r\n");
|
||||
#line 262 "CompilationErrorPage.cshtml"
|
||||
#line 264 "CompilationErrorPage.cshtml"
|
||||
if (frame.PreContextCode.Any())
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <ol");
|
||||
BeginWriteAttribute("start", " start=\"", 5864, "\"", 5893, 1);
|
||||
#line 264 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 5872, frame.PreContextLine, 5872, 21, false);
|
||||
BeginWriteAttribute("start", " start=\"", 5883, "\"", 5912, 1);
|
||||
#line 266 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 5891, frame.PreContextLine, 5891, 21, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(" class=\"collapsible\">\r\n");
|
||||
#line 265 "CompilationErrorPage.cshtml"
|
||||
#line 267 "CompilationErrorPage.cshtml"
|
||||
foreach (var line in frame.PreContextCode)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <li><span>");
|
||||
#line 267 "CompilationErrorPage.cshtml"
|
||||
#line 269 "CompilationErrorPage.cshtml"
|
||||
Write(line);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span></li>\r\n");
|
||||
#line 268 "CompilationErrorPage.cshtml"
|
||||
#line 270 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </ol>\r\n");
|
||||
#line 270 "CompilationErrorPage.cshtml"
|
||||
#line 272 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <ol");
|
||||
BeginWriteAttribute("start", " start=\"", 6274, "\"", 6293, 1);
|
||||
#line 271 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 6282, frame.Line, 6282, 11, false);
|
||||
BeginWriteAttribute("start", " start=\"", 6293, "\"", 6312, 1);
|
||||
#line 273 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 6301, frame.Line, 6301, 11, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(" class=\"highlight\">\r\n");
|
||||
#line 272 "CompilationErrorPage.cshtml"
|
||||
#line 274 "CompilationErrorPage.cshtml"
|
||||
foreach (var line in frame.ContextCode)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <li><span>");
|
||||
#line 274 "CompilationErrorPage.cshtml"
|
||||
#line 276 "CompilationErrorPage.cshtml"
|
||||
Write(line);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span></li>\r\n");
|
||||
#line 275 "CompilationErrorPage.cshtml"
|
||||
#line 277 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </ol>\r\n");
|
||||
#line 277 "CompilationErrorPage.cshtml"
|
||||
#line 279 "CompilationErrorPage.cshtml"
|
||||
if (frame.PostContextCode.Any())
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <ol");
|
||||
BeginWriteAttribute("start", " start=\'", 6720, "\'", 6745, 1);
|
||||
#line 279 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 6728, frame.Line + 1, 6728, 17, false);
|
||||
BeginWriteAttribute("start", " start=\'", 6739, "\'", 6764, 1);
|
||||
#line 281 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 6747, frame.Line + 1, 6747, 17, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(" class=\"collapsible\">\r\n");
|
||||
#line 280 "CompilationErrorPage.cshtml"
|
||||
#line 282 "CompilationErrorPage.cshtml"
|
||||
foreach (var line in frame.PostContextCode)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <li><span>");
|
||||
#line 282 "CompilationErrorPage.cshtml"
|
||||
#line 284 "CompilationErrorPage.cshtml"
|
||||
Write(line);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span></li>\r\n");
|
||||
#line 283 "CompilationErrorPage.cshtml"
|
||||
#line 285 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </ol>\r\n");
|
||||
#line 285 "CompilationErrorPage.cshtml"
|
||||
#line 287 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </div>\r\n");
|
||||
#line 287 "CompilationErrorPage.cshtml"
|
||||
#line 289 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </li>\r\n");
|
||||
#line 289 "CompilationErrorPage.cshtml"
|
||||
#line 291 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </ul>\r\n <br />\r\n </div>\r\n");
|
||||
#line 293 "CompilationErrorPage.cshtml"
|
||||
#line 295 "CompilationErrorPage.cshtml"
|
||||
if (!string.IsNullOrEmpty(Model.CompiledContent[i]))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div class=\"rawExceptionBlock\">\r\n <div class=\"showRawExceptionContainer\">\r\n <button class=\"showRawException\" data-exceptionDetailId=\"");
|
||||
#line 297 "CompilationErrorPage.cshtml"
|
||||
#line 299 "CompilationErrorPage.cshtml"
|
||||
Write(exceptionDetailId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\">Show compilation source</button>\r\n </div>\r\n <div");
|
||||
BeginWriteAttribute("id", " id=\"", 7647, "\"", 7670, 1);
|
||||
#line 299 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 7652, exceptionDetailId, 7652, 18, false);
|
||||
BeginWriteAttribute("id", " id=\"", 7666, "\"", 7689, 1);
|
||||
#line 301 "CompilationErrorPage.cshtml"
|
||||
WriteAttributeValue("", 7671, exceptionDetailId, 7671, 18, false);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
EndWriteAttribute();
|
||||
WriteLiteral(" class=\"rawExceptionDetails\">\r\n <pre class=\"rawExceptionStackTrace\">");
|
||||
#line 300 "CompilationErrorPage.cshtml"
|
||||
#line 302 "CompilationErrorPage.cshtml"
|
||||
Write(Model.CompiledContent[i]);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</pre>\r\n </div>\r\n </div>\r\n");
|
||||
#line 303 "CompilationErrorPage.cshtml"
|
||||
#line 305 "CompilationErrorPage.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
#line 303 "CompilationErrorPage.cshtml"
|
||||
#line 305 "CompilationErrorPage.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Diagnostics.RazorViews
|
||||
{
|
||||
internal class EndpointModel
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string RoutePattern { get; set; }
|
||||
public int? Order { get; set; }
|
||||
public string HttpMethods { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,4 +1,4 @@
|
|||
@using System
|
||||
@using System
|
||||
@using System.Globalization
|
||||
@using System.Linq
|
||||
@using System.Net
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
@foreach (var errorDetail in Model.ErrorDetails)
|
||||
{
|
||||
<div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div>
|
||||
|
||||
|
||||
var firstFrame = errorDetail.StackFrames.FirstOrDefault();
|
||||
if (firstFrame != null)
|
||||
{
|
||||
|
|
@ -80,6 +80,9 @@
|
|||
<li id="headers" tabindex="4">
|
||||
@Resources.ErrorPageHtml_HeadersButton
|
||||
</li>
|
||||
<li id="routing" tabindex="5">
|
||||
@Resources.ErrorPageHtml_RoutingButton
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div id="stackpage" class="page">
|
||||
|
|
@ -98,59 +101,59 @@
|
|||
<li>
|
||||
<h2 class="stackerror">@errorDetail.Error.GetType().Name: @errorDetail.Error.Message</h2>
|
||||
<ul>
|
||||
@foreach (var frame in errorDetail.StackFrames)
|
||||
{
|
||||
stackFrameCount++;
|
||||
frameId = "frame" + stackFrameCount;
|
||||
@foreach (var frame in errorDetail.StackFrames)
|
||||
{
|
||||
stackFrameCount++;
|
||||
frameId = "frame" + stackFrameCount;
|
||||
|
||||
<li class="frame" id="@frameId">
|
||||
@if (string.IsNullOrEmpty(frame.File))
|
||||
{
|
||||
<h3>@frame.Function</h3>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h3>@frame.Function in <code title="@frame.File">@System.IO.Path.GetFileName(frame.File)</code></h3>
|
||||
}
|
||||
<li class="frame" id="@frameId">
|
||||
@if (string.IsNullOrEmpty(frame.File))
|
||||
{
|
||||
<h3>@frame.Function</h3>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h3>@frame.Function in <code title="@frame.File">@System.IO.Path.GetFileName(frame.File)</code></h3>
|
||||
}
|
||||
|
||||
@if (frame.Line != 0 && frame.ContextCode.Any())
|
||||
{
|
||||
<button class="expandCollapseButton" data-frameId="@frameId">+</button>
|
||||
<div class="source">
|
||||
@if (frame.PreContextCode.Any())
|
||||
{
|
||||
<ol start="@frame.PreContextLine" class="collapsible">
|
||||
@foreach (var line in frame.PreContextCode)
|
||||
{
|
||||
<li><span>@line</span></li>
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
|
||||
<ol start="@frame.Line" class="highlight">
|
||||
@foreach (var line in frame.ContextCode)
|
||||
@if (frame.Line != 0 && frame.ContextCode.Any())
|
||||
{
|
||||
<button class="expandCollapseButton" data-frameId="@frameId">+</button>
|
||||
<div class="source">
|
||||
@if (frame.PreContextCode.Any())
|
||||
{
|
||||
<li><span>@line</span></li>
|
||||
<ol start="@frame.PreContextLine" class="collapsible">
|
||||
@foreach (var line in frame.PreContextCode)
|
||||
{
|
||||
<li><span>@line</span></li>
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
</ol>
|
||||
|
||||
@if (frame.PostContextCode.Any())
|
||||
{
|
||||
<ol start='@(frame.Line + 1)' class="collapsible">
|
||||
@foreach (var line in frame.PostContextCode)
|
||||
<ol start="@frame.Line" class="highlight">
|
||||
@foreach (var line in frame.ContextCode)
|
||||
{
|
||||
<li><span>@line</span></li>
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
|
||||
@if (frame.PostContextCode.Any())
|
||||
{
|
||||
<ol start='@(frame.Line + 1)' class="collapsible">
|
||||
@foreach (var line in frame.PostContextCode)
|
||||
{
|
||||
<li><span>@line</span></li>
|
||||
}
|
||||
</ol>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<br/>
|
||||
<br />
|
||||
<div class="rawExceptionBlock">
|
||||
<div class="showRawExceptionContainer">
|
||||
<button class="showRawException" data-exceptionDetailId="@exceptionDetailId">Show raw exception details</button>
|
||||
|
|
@ -220,6 +223,7 @@
|
|||
<p>@Resources.ErrorPageHtml_NoCookieData</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div id="headerspage" class="page">
|
||||
@if (Model.Headers.Any())
|
||||
{
|
||||
|
|
@ -249,6 +253,78 @@
|
|||
<p>@Resources.ErrorPageHtml_NoHeaderData</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div id="routingpage" class="page">
|
||||
<h2 class="subheader">@Resources.ErrorPageHtml_Endpoint</h2>
|
||||
@if (Model.Endpoint != null)
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Resources.ErrorPageHtml_NameColumn</th>
|
||||
<th>@Resources.ErrorPageHtml_ValueColumn</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>@Resources.ErrorPageHtml_EndpointDisplayName</td>
|
||||
<td>@Model.Endpoint.DisplayName</td>
|
||||
</tr>
|
||||
@if (!string.IsNullOrEmpty(Model.Endpoint.RoutePattern))
|
||||
{
|
||||
<tr>
|
||||
<td>@Resources.ErrorPageHtml_EndpointRoutePattern</td>
|
||||
<td>@Model.Endpoint.RoutePattern</td>
|
||||
</tr>
|
||||
}
|
||||
@if (Model.Endpoint.Order != null)
|
||||
{
|
||||
<tr>
|
||||
<td>@Resources.ErrorPageHtml_EndpointRouteOrder</td>
|
||||
<td>@Model.Endpoint.Order</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(Model.Endpoint.HttpMethods))
|
||||
{
|
||||
<tr>
|
||||
<td>@Resources.ErrorPageHtml_EndpointRouteHttpMethod</td>
|
||||
<td>@Model.Endpoint.HttpMethods</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>@Resources.ErrorPageHtml_NoEndpoint</p>
|
||||
}
|
||||
<h2 class="subheader">@Resources.ErrorPageHtml_RouteValues</h2>
|
||||
@if (Model.RouteValues != null && Model.RouteValues.Any())
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@Resources.ErrorPageHtml_VariableColumn</th>
|
||||
<th>@Resources.ErrorPageHtml_ValueColumn</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var kv in Model.RouteValues.OrderBy(kv => kv.Key))
|
||||
{
|
||||
<tr>
|
||||
<td>@kv.Key</td>
|
||||
<td>@kv.Value</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>@Resources.ErrorPageHtml_NoRouteValues</p>
|
||||
}
|
||||
</div>
|
||||
|
||||
<script>
|
||||
//<!--
|
||||
<%$ include: ErrorPage.js %>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
body {
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;
|
||||
font-size: .813em;
|
||||
color: #222;
|
||||
|
|
@ -108,6 +108,11 @@ body .location {
|
|||
color: #606060;
|
||||
}
|
||||
|
||||
#routingpage .subheader {
|
||||
padding: 5px;
|
||||
border-bottom: 1px #ddd solid;
|
||||
}
|
||||
|
||||
.page table {
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Microsoft.Extensions.StackTrace.Sources;
|
||||
|
||||
|
|
@ -38,5 +39,15 @@ namespace Microsoft.AspNetCore.Diagnostics.RazorViews
|
|||
/// Request headers.
|
||||
/// </summary>
|
||||
public IDictionary<string, StringValues> Headers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Request route values.
|
||||
/// </summary>
|
||||
public RouteValueDictionary RouteValues { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Request endpoint.
|
||||
/// </summary>
|
||||
public EndpointModel Endpoint { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Description>ASP.NET Core middleware for exception handling, exception display pages, and diagnostics information. Includes developer exception page middleware, exception handler middleware, runtime info middleware, status code page middleware, and welcome page middleware</Description>
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<Reference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Hosting.Abstractions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Http.Extensions" />
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
<Reference Include="Microsoft.AspNetCore.WebUtilities" />
|
||||
<Reference Include="Microsoft.Extensions.FileProviders.Physical" />
|
||||
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
=> GetString("ErrorPageHtml_NoHeaderData");
|
||||
|
||||
/// <summary>
|
||||
/// No QueryString data.
|
||||
/// No query string data.
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_NoQueryStringData
|
||||
{
|
||||
|
|
@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// No QueryString data.
|
||||
/// No query string data.
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_NoQueryStringData()
|
||||
=> GetString("ErrorPageHtml_NoQueryStringData");
|
||||
|
|
@ -598,6 +598,146 @@ namespace Microsoft.AspNetCore.Diagnostics
|
|||
internal static string FormatExceptionHandlerOptions_NotConfiguredCorrectly()
|
||||
=> GetString("ExceptionHandlerOptions_NotConfiguredCorrectly");
|
||||
|
||||
/// <summary>
|
||||
/// No route values.
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_NoRouteValues
|
||||
{
|
||||
get => GetString("ErrorPageHtml_NoRouteValues");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No route values.
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_NoRouteValues()
|
||||
=> GetString("ErrorPageHtml_NoRouteValues");
|
||||
|
||||
/// <summary>
|
||||
/// Routing
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_RoutingButton
|
||||
{
|
||||
get => GetString("ErrorPageHtml_RoutingButton");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Routing
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_RoutingButton()
|
||||
=> GetString("ErrorPageHtml_RoutingButton");
|
||||
|
||||
/// <summary>
|
||||
/// Endpoint
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_Endpoint
|
||||
{
|
||||
get => GetString("ErrorPageHtml_Endpoint");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Endpoint
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_Endpoint()
|
||||
=> GetString("ErrorPageHtml_Endpoint");
|
||||
|
||||
/// <summary>
|
||||
/// Display Name
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_EndpointDisplayName
|
||||
{
|
||||
get => GetString("ErrorPageHtml_EndpointDisplayName");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Display Name
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_EndpointDisplayName()
|
||||
=> GetString("ErrorPageHtml_EndpointDisplayName");
|
||||
|
||||
/// <summary>
|
||||
/// Route Order
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_EndpointRouteOrder
|
||||
{
|
||||
get => GetString("ErrorPageHtml_EndpointRouteOrder");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Route Order
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_EndpointRouteOrder()
|
||||
=> GetString("ErrorPageHtml_EndpointRouteOrder");
|
||||
|
||||
/// <summary>
|
||||
/// Route HTTP Method
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_EndpointRouteHttpMethod
|
||||
{
|
||||
get => GetString("ErrorPageHtml_EndpointRouteHttpMethod");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Route HTTP Method
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_EndpointRouteHttpMethod()
|
||||
=> GetString("ErrorPageHtml_EndpointRouteHttpMethod");
|
||||
|
||||
/// <summary>
|
||||
/// Route Pattern
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_EndpointRoutePattern
|
||||
{
|
||||
get => GetString("ErrorPageHtml_EndpointRoutePattern");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Route Pattern
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_EndpointRoutePattern()
|
||||
=> GetString("ErrorPageHtml_EndpointRoutePattern");
|
||||
|
||||
/// <summary>
|
||||
/// No endpoint.
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_NoEndpoint
|
||||
{
|
||||
get => GetString("ErrorPageHtml_NoEndpoint");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No endpoint.
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_NoEndpoint()
|
||||
=> GetString("ErrorPageHtml_NoEndpoint");
|
||||
|
||||
/// <summary>
|
||||
/// Route Values
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_RouteValues
|
||||
{
|
||||
get => GetString("ErrorPageHtml_RouteValues");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Route Values
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_RouteValues()
|
||||
=> GetString("ErrorPageHtml_RouteValues");
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
internal static string ErrorPageHtml_NameColumn
|
||||
{
|
||||
get => GetString("ErrorPageHtml_NameColumn");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name
|
||||
/// </summary>
|
||||
internal static string FormatErrorPageHtml_NameColumn()
|
||||
=> GetString("ErrorPageHtml_NameColumn");
|
||||
|
||||
private static string GetString(string name, params string[] formatterNames)
|
||||
{
|
||||
var value = _resourceManager.GetString(name);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
ASP.NET Core Diagnostics
|
||||
===
|
||||
|
||||
## Development
|
||||
|
||||
Diagnostics middleware like `DeveloperExceptionPage` uses compiled Razor views. After updating the `*.cshtml` file you must run the [RazorPageGenerator](https://github.com/aspnet/AspNetCore-Tooling/tree/master/src/Razor/src/RazorPageGenerator) tool to generate an updated compiled Razor view.
|
||||
|
||||
Run the following command in `AspNetCore-Tooling\src\Razor\src\RazorPageGenerator`:
|
||||
|
||||
```
|
||||
dotnet run Microsoft.AspNetCore.Diagnostics.RazorViews path-to-aspnetcore-middleware-diagnostics-src
|
||||
```
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
<value>No header data.</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_NoQueryStringData" xml:space="preserve">
|
||||
<value>No QueryString data.</value>
|
||||
<value>No query string data.</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_QueryButton" xml:space="preserve">
|
||||
<value>Query</value>
|
||||
|
|
@ -250,4 +250,34 @@
|
|||
<data name="ExceptionHandlerOptions_NotConfiguredCorrectly" xml:space="preserve">
|
||||
<value>An error occurred when configuring the exception handler middleware. Either the 'ExceptionHandlingPath' or the 'ExceptionHandler' option must be set in 'UseExceptionHandler()'.</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_NoRouteValues" xml:space="preserve">
|
||||
<value>No route values.</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_RoutingButton" xml:space="preserve">
|
||||
<value>Routing</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_Endpoint" xml:space="preserve">
|
||||
<value>Endpoint</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_EndpointDisplayName" xml:space="preserve">
|
||||
<value>Display Name</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_EndpointRouteOrder" xml:space="preserve">
|
||||
<value>Route Order</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_EndpointRouteHttpMethod" xml:space="preserve">
|
||||
<value>Route HTTP Method</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_EndpointRoutePattern" xml:space="preserve">
|
||||
<value>Route Pattern</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_NoEndpoint" xml:space="preserve">
|
||||
<value>No endpoint.</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_RouteValues" xml:space="preserve">
|
||||
<value>Route Values</value>
|
||||
</data>
|
||||
<data name="ErrorPageHtml_NameColumn" xml:space="preserve">
|
||||
<value>Name</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.Routing" />
|
||||
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
|
||||
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Endpoints;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Routing.Patterns;
|
||||
|
||||
namespace DeveloperExceptionPageSample
|
||||
{
|
||||
|
|
@ -8,6 +16,24 @@ namespace DeveloperExceptionPageSample
|
|||
{
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.Use((context, next) =>
|
||||
{
|
||||
context.Request.RouteValues = new RouteValueDictionary(new
|
||||
{
|
||||
routeValue1 = "Value1",
|
||||
routeValue2 = "Value2",
|
||||
});
|
||||
|
||||
var endpoint = new RouteEndpoint(
|
||||
c => null,
|
||||
RoutePatternFactory.Parse("/"),
|
||||
0,
|
||||
new EndpointMetadataCollection(new HttpMethodMetadata(new[] { "GET", "POST" })),
|
||||
"Endpoint display name");
|
||||
|
||||
context.SetEndpoint(endpoint);
|
||||
return next();
|
||||
});
|
||||
app.UseDeveloperExceptionPage();
|
||||
app.Run(context =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue