parent
27a8002e75
commit
2766113ba9
|
|
@ -1,73 +0,0 @@
|
|||
namespace Microsoft.AspNet.Diagnostics.Views
|
||||
{
|
||||
#line 1 "DiagnosticsPage.cshtml"
|
||||
using System
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
;
|
||||
#line 2 "DiagnosticsPage.cshtml"
|
||||
using System.Globalization
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
public class DiagnosticsPage : Microsoft.AspNet.Diagnostics.Views.BaseView
|
||||
{
|
||||
#line hidden
|
||||
public DiagnosticsPage()
|
||||
{
|
||||
}
|
||||
|
||||
#pragma warning disable 1998
|
||||
public override async Task ExecuteAsync()
|
||||
{
|
||||
#line 3 "DiagnosticsPage.cshtml"
|
||||
|
||||
Response.ContentType = "text/html";
|
||||
string error = Request.Query["error"];
|
||||
if (!string.IsNullOrWhiteSpace(error))
|
||||
{
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "User requested error '{0}'", error));
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteral("\r\n<!DOCTYPE html>\r\n\r\n<html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head" +
|
||||
">\r\n <meta charset=\"utf-8\" />\r\n <title>");
|
||||
#line 16 "DiagnosticsPage.cshtml"
|
||||
Write(Resources.DiagnosticsPageHtml_Title);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</title>\r\n</head>\r\n<body>\r\n <div class=\"main\">\r\n <h1>");
|
||||
#line 20 "DiagnosticsPage.cshtml"
|
||||
Write(Resources.DiagnosticsPageHtml_Title);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h1>\r\n <p>");
|
||||
#line 21 "DiagnosticsPage.cshtml"
|
||||
Write(Resources.DiagnosticsPageHtml_Information);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</p>\r\n </div>\r\n <div class=\"errors\">\r\n <h2>");
|
||||
#line 24 "DiagnosticsPage.cshtml"
|
||||
Write(Resources.DiagnosticsPageHtml_TestErrorSection);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</h2>\r\n <p><a");
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 763), Tuple.Create("\"", 854),
|
||||
Tuple.Create(Tuple.Create("", 770), Tuple.Create<System.Object, System.Int32>(Request.PathBase, 770), false),
|
||||
Tuple.Create(Tuple.Create("", 787), Tuple.Create<System.Object, System.Int32>(Request.Path, 787), false), Tuple.Create(Tuple.Create("", 800), Tuple.Create("?error=", 800), true),
|
||||
Tuple.Create(Tuple.Create("", 807), Tuple.Create<System.Object, System.Int32>(Resources.DiagnosticsPageHtml_TestErrorMessage, 807), false));
|
||||
WriteLiteral(">throw InvalidOperationException</a></p>\r\n </div>\r\n</body>\r\n</html>\r\n");
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
@using System
|
||||
@using System.Globalization
|
||||
@{
|
||||
Response.ContentType = "text/html";
|
||||
string error = Request.Query["error"];
|
||||
if (!string.IsNullOrWhiteSpace(error))
|
||||
{
|
||||
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "User requested error '{0}'", error));
|
||||
}
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>@Resources.DiagnosticsPageHtml_Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="main">
|
||||
<h1>@Resources.DiagnosticsPageHtml_Title</h1>
|
||||
<p>@Resources.DiagnosticsPageHtml_Information</p>
|
||||
</div>
|
||||
<div class="errors">
|
||||
<h2>@Resources.DiagnosticsPageHtml_TestErrorSection</h2>
|
||||
<p><a href="@Request.PathBase@Request.Path?error=@Resources.DiagnosticsPageHtml_TestErrorMessage">throw InvalidOperationException</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// 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.
|
||||
|
||||
|
||||
#if DIAGNOSTICS_PAGE_MIDDLEWARE
|
||||
using System;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.Framework.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Builder
|
||||
{
|
||||
/// <summary>
|
||||
/// IApplicationBuilder extensions for the DiagnosticsPageMiddleware.
|
||||
/// </summary>
|
||||
public static class DiagnosticsPageExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the DiagnosticsPageMiddleware to the pipeline with the given options.
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseDiagnosticsPage([NotNull] this IApplicationBuilder builder, DiagnosticsPageOptions options)
|
||||
{
|
||||
return builder.Use(next => new DiagnosticsPageMiddleware(next, options).Invoke);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the DiagnosticsPageMiddleware to the pipeline with the given path.
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseDiagnosticsPage(this IApplicationBuilder builder, PathString path)
|
||||
{
|
||||
return UseDiagnosticsPage(builder, new DiagnosticsPageOptions { Path = path });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the DiagnosticsPageMiddleware to the pipeline.
|
||||
/// </summary>
|
||||
/// <param name="builder"></param>
|
||||
/// <returns></returns>
|
||||
public static IApplicationBuilder UseDiagnosticsPage(this IApplicationBuilder builder)
|
||||
{
|
||||
return UseDiagnosticsPage(builder, new DiagnosticsPageOptions());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// 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.
|
||||
|
||||
|
||||
#if DIAGNOSTICS_PAGE_MIDDLEWARE
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Diagnostics.Views;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics
|
||||
{
|
||||
/// <summary>
|
||||
/// A human readable page with basic debugging actions.
|
||||
/// </summary>
|
||||
public class DiagnosticsPageMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
private readonly DiagnosticsPageOptions _options;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DiagnosticsPageMiddleware"/> class
|
||||
/// </summary>
|
||||
/// <param name="next"></param>
|
||||
/// <param name="options"></param>
|
||||
public DiagnosticsPageMiddleware(RequestDelegate next, DiagnosticsPageOptions options)
|
||||
{
|
||||
_next = next;
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process an individual request.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public Task Invoke(HttpContext context)
|
||||
{
|
||||
if (!_options.Path.HasValue || _options.Path == context.Request.Path)
|
||||
{
|
||||
var page = new DiagnosticsPage();
|
||||
page.Execute(context);
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
return _next(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// 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.
|
||||
|
||||
|
||||
#if DIAGNOSTICS_PAGE_MIDDLEWARE
|
||||
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Diagnostics
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for the DiagnosticsPageMiddleware
|
||||
/// </summary>
|
||||
public class DiagnosticsPageOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies which requests paths will be responded to. Exact matches only. Leave null to handle all requests.
|
||||
/// </summary>
|
||||
public PathString Path { get; set; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Reference in New Issue