From e076040b67c3a2645661c18858f7af497e5db26c Mon Sep 17 00:00:00 2001
From: John Luo
Date: Thu, 7 Jan 2016 15:31:41 -0800
Subject: [PATCH] Updating to new options pattern
---
.../ElmServiceCollectionExtensions.cs | 3 +-
.../Views/DetailsPage.cs | 35 +-
.../Views/LogPage.cs | 8 +-
.../DatabaseErrorPageExtensions.cs | 63 +-
.../DatabaseErrorPageMiddleware.cs | 5 +-
.../DatabaseErrorPageOptions.cs | 22 +-
.../MigrationsEndPointExtensions.cs | 30 +-
.../MigrationsEndPointMiddleware.cs | 5 +-
.../MigrationsEndPointOptions.cs | 2 +-
.../Views/DatabaseErrorPage.cs | 264 ++----
.../Views/DatabaseErrorPage.cshtml | 107 ++-
.../DeveloperExceptionPageExtensions.cs | 30 +-
.../DeveloperExceptionPageMiddleware.cs | 8 +-
.../DeveloperExceptionPageOptions.cs | 3 +-
.../Views/CompilationErrorModel.cs | 1 +
.../Views/CompilationErrorPage.cs | 9 +-
.../DeveloperExceptionPage/Views/ErrorPage.cs | 39 +-
.../Views/ErrorPageModel.cs | 1 +
.../ExceptionHandlerExtensions.cs | 51 +-
.../ExceptionHandlerMiddleware.cs | 6 +-
.../ExceptionHandlerOptions.cs | 2 +-
.../RuntimeInfo/RuntimeInfoExtensions.cs | 28 +-
.../RuntimeInfo/RuntimeInfoMiddleware.cs | 6 +-
.../RuntimeInfo/RuntimeInfoPageOptions.cs | 2 +-
.../RuntimeInfo/Views/RuntimeInfoPage.cs | 6 +-
.../StatusCodePagesExtensions.cs | 35 +-
.../StatusCodePagesMiddleware.cs | 6 +-
.../StatusCodePage/StatusCodePagesOptions.cs | 3 +-
.../WelcomePage/Views/WelcomePage.cs | 826 +++++-------------
.../WelcomePage/WelcomePageExtensions.cs | 38 +-
.../WelcomePage/WelcomePageMiddleware.cs | 6 +-
.../WelcomePage/WelcomePageOptions.cs | 2 +-
.../DatabaseErrorPageMiddlewareTest.cs | 5 +-
.../MigrationsEndPointMiddlewareTest.cs | 5 +-
.../DatabaseErrorPageOptionsTest.cs | 62 +-
.../DatabaseErrorPageTest.cs | 70 +-
.../DeveloperExceptionPageMiddlewareTest.cs | 3 +-
.../RuntimeInfoMiddlewareTest.cs | 10 +-
38 files changed, 513 insertions(+), 1294 deletions(-)
diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs
index 0b73d38d8a..9a4ab485b1 100644
--- a/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Elm/ElmServiceCollectionExtensions.cs
@@ -17,8 +17,7 @@ namespace Microsoft.Extensions.DependencyInjection
{
throw new ArgumentNullException(nameof(services));
}
-
- services.AddOptions();
+
services.AddSingleton();
return services;
}
diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.cs
index 7dc6369423..d50bbdc12c 100644
--- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/DetailsPage.cs
@@ -174,37 +174,31 @@ using Microsoft.Extensions.Logging
#line default
#line hidden
- WriteLiteral(" \r\n \r\n \r\n\r\n " +
-" \r\n | Path | \r\n ");
+ WriteLiteral(" \r\n \r\n \r\n\r\n \r\n | Path | \r\n ");
#line 110 "DetailsPage.cshtml"
Write(context.Path);
#line default
#line hidden
- WriteLiteral(" | \r\n \r\n \r\n | Host | \r\n " +
-" ");
+ WriteLiteral(" | \r\n \r\n \r\n | Host | \r\n ");
#line 114 "DetailsPage.cshtml"
Write(context.Host);
#line default
#line hidden
- WriteLiteral(" | \r\n \r\n \r\n | Content Type | " +
-"\r\n ");
+ WriteLiteral(" | \r\n \r\n \r\n | Content Type | \r\n ");
#line 118 "DetailsPage.cshtml"
Write(context.ContentType);
#line default
#line hidden
- WriteLiteral(" | \r\n \r\n \r\n | Method | \r\n " +
-" ");
+ WriteLiteral(" | \r\n \r\n \r\n | Method | \r\n ");
#line 122 "DetailsPage.cshtml"
Write(context.Method);
#line default
#line hidden
- WriteLiteral(" | \r\n \r\n \r\n | Protocol | \r\n " +
-" ");
+ WriteLiteral(" | \r\n \r\n \r\n | Protocol | \r\n ");
#line 126 "DetailsPage.cshtml"
Write(context.Protocol);
@@ -256,23 +250,19 @@ using Microsoft.Extensions.Logging
#line default
#line hidden
- WriteLiteral(" \r\n | \r\n <" +
-"/td>\r\n |
\r\n \r\n | Status Code | \r" +
-"\n ");
+ WriteLiteral(" \r\n |
\r\n \r\n \r\n \r\n | Status Code | \r\n ");
#line 152 "DetailsPage.cshtml"
Write(context.StatusCode);
#line default
#line hidden
- WriteLiteral(" | \r\n
\r\n \r\n | User | \r\n " +
-" ");
+ WriteLiteral(" | \r\n
\r\n \r\n | User | \r\n ");
#line 156 "DetailsPage.cshtml"
Write(context.User.Identity.Name);
#line default
#line hidden
- WriteLiteral(" | \r\n
\r\n \r\n | Claims | \r\n " +
-" \r\n");
+ WriteLiteral(" | \r\n
\r\n \r\n | Claims | \r\n \r\n");
#line 161 "DetailsPage.cshtml"
@@ -334,22 +324,19 @@ using Microsoft.Extensions.Logging
#line default
#line hidden
- WriteLiteral(" | \r\n
\r\n \r\n | S" +
-"cheme | \r\n ");
+ WriteLiteral(" | \r\n
\r\n \r\n | Scheme | \r\n ");
#line 185 "DetailsPage.cshtml"
Write(context.Scheme);
#line default
#line hidden
- WriteLiteral(" | \r\n
\r\n \r\n | Query | \r\n " +
-" ");
+ WriteLiteral(" | \r\n
\r\n \r\n | Query | \r\n ");
#line 189 "DetailsPage.cshtml"
Write(context.Query.Value);
#line default
#line hidden
- WriteLiteral(" | \r\n
\r\n \r\n | Cookies | \r\n " +
-" \r\n");
+ WriteLiteral(" | \r\n
\r\n \r\n | Cookies | \r\n \r\n");
#line 194 "DetailsPage.cshtml"
diff --git a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs
index 0153b8ff58..aab5a24948 100644
--- a/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Elm/Views/LogPage.cs
@@ -485,9 +485,7 @@ WriteAttributeValue("", 6944, activityPath, 6944, 13, false);
#line default
#line hidden
- WriteLiteral(" \r\n |
\r\n \r\n " +
-" | ");
+ WriteLiteral(" |
\r\n \r\n \r\n | ");
#line 227 "LogPage.cshtml"
Write(activity.Time.ToString("MM-dd-yyyy HH:mm:ss"));
@@ -549,9 +547,7 @@ WriteAttributeValue("", 6944, activityPath, 6944, 13, false);
#line default
#line hidden
- WriteLiteral(" |
\r\n \r\n " +
-" \r\n \r\n \r\n" +
-" \r\n");
+ WriteLiteral(" \r\n \r\n \r\n \r\n \r\n \r\n");
#line 244 "LogPage.cshtml"
}
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs
index 7204ba687b..9e08330fa2 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageExtensions.cs
@@ -1,10 +1,9 @@
// 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 JetBrains.Annotations;
-using Microsoft.AspNet.Diagnostics.Entity;
-using Microsoft.AspNet.Diagnostics.Entity.Utilities;
using System;
+using Microsoft.AspNet.Diagnostics.Entity;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Builder
{
@@ -27,38 +26,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(app));
}
- return app.UseDatabaseErrorPage(options => options.EnableAll());
- }
-
- ///
- /// Captures synchronous and asynchronous database related exceptions from the pipeline that may be resolved using Entity Framework
- /// migrations. When these exceptions occur an HTML response with details of possible actions to resolve the issue is generated.
- ///
- /// The to register the middleware with.
- /// An action to set the options for the middleware. All options are disabled by default.
- /// The same instance so that multiple calls can be chained.
- public static IApplicationBuilder UseDatabaseErrorPage(this IApplicationBuilder app, Action configureOptions)
- {
- if (app == null)
- {
- throw new ArgumentNullException(nameof(app));
- }
- if (configureOptions == null)
- {
- throw new ArgumentNullException(nameof(configureOptions));
- }
-
- var options = new DatabaseErrorPageOptions();
- configureOptions(options);
-
- app = app.UseMiddleware(options);
-
- if (options.EnableMigrationCommands)
- {
- app.UseMigrationsEndPoint(o => o.Path = options.MigrationsEndPointPath);
- }
-
- return app;
+ return app.UseMiddleware();
}
///
@@ -79,31 +47,14 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(options));
}
- app = app.UseMiddleware(options);
+ app = app.UseMiddleware(Options.Create(options));
- if (options.EnableMigrationCommands)
+ app.UseMigrationsEndPoint(new MigrationsEndPointOptions
{
- app.UseMigrationsEndPoint(o => o.Path = options.MigrationsEndPointPath);
- }
+ Path = options.MigrationsEndPointPath
+ });
return app;
}
-
- ///
- /// Sets the options to display the maximum amount of information available.
- ///
- /// The options to be configured.
- public static void EnableAll(this DatabaseErrorPageOptions options)
- {
- if (options == null)
- {
- throw new ArgumentNullException(nameof(options));
- }
-
- options.ShowExceptionDetails = true;
- options.ListMigrations = true;
- options.EnableMigrationCommands = true;
- options.MigrationsEndPointPath = MigrationsEndPointOptions.DefaultPath;
- }
}
}
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs
index deb51bd8f5..8ee98c3485 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageMiddleware.cs
@@ -14,6 +14,7 @@ using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Storage;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Diagnostics.Entity
{
@@ -39,7 +40,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
/// consumes them to detect database related exception.
///
/// The options to control what information is displayed on the error page.
- public DatabaseErrorPageMiddleware([NotNull] RequestDelegate next, [NotNull] IServiceProvider serviceProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] DatabaseErrorPageOptions options)
+ public DatabaseErrorPageMiddleware([NotNull] RequestDelegate next, [NotNull] IServiceProvider serviceProvider, [NotNull] ILoggerFactory loggerFactory, [NotNull] IOptions options)
{
Check.NotNull(next, nameof(next));
Check.NotNull(serviceProvider, nameof(serviceProvider));
@@ -48,7 +49,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
_next = next;
_serviceProvider = serviceProvider;
- _options = options;
+ _options = options.Value;
_logger = loggerFactory.CreateLogger();
_loggerProvider = new DataStoreErrorLoggerProvider();
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs
index 38d9318b47..eee344e7f4 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/DatabaseErrorPageOptions.cs
@@ -3,36 +3,18 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Diagnostics.Entity
+namespace Microsoft.AspNet.Builder
{
///
/// Options for the .
///
public class DatabaseErrorPageOptions
{
- ///
- /// Gets or sets a value indicating whether details about the exception that occurred
- /// are displayed on the error page.
- ///
- public virtual bool ShowExceptionDetails { get; set; }
-
- ///
- /// Gets or sets a value indicating whether the names of pending migrations are listed
- /// on the error page.
- ///
- public virtual bool ListMigrations { get; set; }
-
- ///
- /// Gets or sets a value indicating whether the error page will allow the execution of
- /// migrations related commands when they may help solve the current error.
- ///
- public virtual bool EnableMigrationCommands { get; set; }
-
///
/// Gets or sets the path that will listen
/// for requests to execute migrations commands. The middleware is only registered if
/// is set to true.
///
- public virtual PathString MigrationsEndPointPath { get; set; }
+ public virtual PathString MigrationsEndPointPath { get; set; } = MigrationsEndPointOptions.DefaultPath;
}
}
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs
index e03fbeb057..4d4cc03973 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointExtensions.cs
@@ -2,9 +2,8 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
-using JetBrains.Annotations;
using Microsoft.AspNet.Diagnostics.Entity;
-using Microsoft.AspNet.Diagnostics.Entity.Utilities;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Builder
{
@@ -25,30 +24,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(app));
}
- return app.UseMigrationsEndPoint(options => { });
- }
-
- ///
- /// Processes requests to execute migrations operations. The middleware will listen for requests to the path configured in .
- ///
- /// The to register the middleware with.
- /// An action to set the options for the middleware.
- /// The same instance so that multiple calls can be chained.
- public static IApplicationBuilder UseMigrationsEndPoint(this IApplicationBuilder app, Action configureOptions)
- {
- if (app == null)
- {
- throw new ArgumentNullException(nameof(app));
- }
- if (configureOptions == null)
- {
- throw new ArgumentNullException(nameof(configureOptions));
- }
-
- var options = new MigrationsEndPointOptions();
- configureOptions(options);
-
- return app.UseMiddleware(options);
+ return app.UseMiddleware();
}
///
@@ -68,7 +44,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(options));
}
- return app.UseMiddleware(options);
+ return app.UseMiddleware(Options.Create(options));
}
}
}
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs
index 078e41465e..079c8b23b9 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointMiddleware.cs
@@ -10,6 +10,7 @@ using Microsoft.AspNet.Diagnostics.Entity.Utilities;
using Microsoft.AspNet.Http;
using Microsoft.Data.Entity;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Diagnostics.Entity
{
@@ -34,7 +35,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
[NotNull] RequestDelegate next,
[NotNull] IServiceProvider serviceProvider,
[NotNull] ILogger logger,
- [NotNull] MigrationsEndPointOptions options)
+ [NotNull] IOptions options)
{
Check.NotNull(next, "next");
Check.NotNull(serviceProvider, "serviceProvider");
@@ -44,7 +45,7 @@ namespace Microsoft.AspNet.Diagnostics.Entity
_next = next;
_serviceProvider = serviceProvider;
_logger = logger;
- _options = options;
+ _options = options.Value;
}
///
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs
index 1f9bb2d780..460e965d43 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/MigrationsEndPointOptions.cs
@@ -3,7 +3,7 @@
using Microsoft.AspNet.Http;
-namespace Microsoft.AspNet.Diagnostics.Entity
+namespace Microsoft.AspNet.Builder
{
///
/// Options for the .
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cs b/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cs
index 7336db3947..97797646bd 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cs
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cs
@@ -61,77 +61,53 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
#line default
#line hidden
- WriteLiteral("\r\n\r\n\r\n\r" +
-"\n \r\n Internal Server Error\r\n \r\n body {\r\n font-family: 'Segoe UI', Tahoma, Arial, Helvetica, sans-serif;\r\n font-size: .813em;\r\n line-height: 1.4em;\r\n color: #222;\r\n}\r\n\r\nh1, h2, h3, h4, h5 {\r\n font-weight: 100;\r\n}\r\n\r\nh1 {\r\n color: #44525e;\r\n margin: 15px 0 15px 0;\r\n}\r\n\r\nh2 {\r\n margin: 10px 5px 0 0;\r\n}\r\n\r\nh3 {\r\n color: #363636;\r\n margin: 5px 5px 0 0;\r\n}\r\n\r\ncode {\r\n font-family: Consolas, \"Courier New\", courier, monospace;\r\n}\r\n\r\na {\r\n color: #1ba1e2;\r\n text-decoration: none;\r\n}\r\n\r\n a:hover {\r\n color: #13709e;\r\n text-decoration: underline;\r\n }\r\n\r\nhr {\r\n border: 1px #ddd solid;\r\n}\r\n\r\nbody .titleerror {\r\n padding: 3px;\r\n}\r\n\r\n#applyMigrations {\r\n font-size: 14px;\r\n background: #44c5f2;\r\n color: #ffffff;\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n font-weight: normal;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n cursor: pointer;\r\n border: 1px solid transparent;\r\n}\r\n\r\n #applyMigrations:disabled {\r\n background-color: #a9e4f9;\r\n border-color: #44c5f2;\r\n }\r\n\r\n.error {\r\n color: red;\r\n}\r\n\r\n.expanded {\r\n display: block;\r\n}\r\n\r\n.collapsed {\r\n display: none;\r\n}\r\n\r\n \r\n\r\n\r\n" +
-" ");
+ WriteLiteral("\r\n\r\n\r\n\r\n \r\n Internal Server Error\r\n \r\n\r\n\r\n ");
#line 35 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_Title);
#line default
#line hidden
- WriteLiteral("
\r\n");
-#line 36 "DatabaseErrorPage.cshtml"
-
+ WriteLiteral("
\r\n \r\n");
+#line 37 "DatabaseErrorPage.cshtml"
+
#line default
#line hidden
-#line 36 "DatabaseErrorPage.cshtml"
- if (Model.Options.ShowExceptionDetails)
- {
+#line 37 "DatabaseErrorPage.cshtml"
+ for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
+ {
#line default
#line hidden
- WriteLiteral("
\r\n");
+ WriteLiteral(" ");
#line 39 "DatabaseErrorPage.cshtml"
-
-
-#line default
-#line hidden
-
-#line 39 "DatabaseErrorPage.cshtml"
- for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
- {
-
-#line default
-#line hidden
-
- WriteLiteral(" ");
-#line 41 "DatabaseErrorPage.cshtml"
- Write(ex.GetType().Name);
+ Write(ex.GetType().Name);
#line default
#line hidden
WriteLiteral(": ");
+#line 39 "DatabaseErrorPage.cshtml"
+ Write(ex.Message);
+
+#line default
+#line hidden
+ WriteLiteral("\r\n
\r\n");
#line 41 "DatabaseErrorPage.cshtml"
- Write(ex.Message);
-
-#line default
-#line hidden
- WriteLiteral("\r\n
\r\n");
-#line 43 "DatabaseErrorPage.cshtml"
- }
+ }
#line default
#line hidden
- WriteLiteral("
\r\n
\r\n");
-#line 46 "DatabaseErrorPage.cshtml"
- }
-
-#line default
-#line hidden
-
- WriteLiteral("\r\n");
-#line 48 "DatabaseErrorPage.cshtml"
+ WriteLiteral("
\r\n
\r\n\r\n");
+#line 45 "DatabaseErrorPage.cshtml"
#line default
#line hidden
-#line 48 "DatabaseErrorPage.cshtml"
+#line 45 "DatabaseErrorPage.cshtml"
if (!Model.DatabaseExists && !Model.PendingMigrations.Any())
{
@@ -139,31 +115,31 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
#line hidden
WriteLiteral(" ");
-#line 50 "DatabaseErrorPage.cshtml"
+#line 47 "DatabaseErrorPage.cshtml"
Write(Strings.FormatDatabaseErrorPage_NoDbOrMigrationsTitle(Model.ContextType.Name));
#line default
#line hidden
WriteLiteral("
\r\n ");
-#line 51 "DatabaseErrorPage.cshtml"
+#line 48 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_NoDbOrMigrationsInfo);
#line default
#line hidden
WriteLiteral("
\r\n ");
-#line 52 "DatabaseErrorPage.cshtml"
+#line 49 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_AddMigrationCommand);
#line default
#line hidden
WriteLiteral(" \r\n
\r\n ");
-#line 54 "DatabaseErrorPage.cshtml"
+#line 51 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_ApplyMigrationsCommand);
#line default
#line hidden
WriteLiteral(" \r\n
\r\n");
-#line 56 "DatabaseErrorPage.cshtml"
+#line 53 "DatabaseErrorPage.cshtml"
}
else if (Model.PendingMigrations.Any())
{
@@ -172,178 +148,132 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
#line hidden
WriteLiteral(" \r\n
");
-#line 60 "DatabaseErrorPage.cshtml"
+#line 57 "DatabaseErrorPage.cshtml"
Write(Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name));
#line default
#line hidden
WriteLiteral("
\r\n
");
-#line 61 "DatabaseErrorPage.cshtml"
+#line 58 "DatabaseErrorPage.cshtml"
Write(Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name));
#line default
#line hidden
- WriteLiteral("
\r\n\r\n");
+ WriteLiteral("\r\n\r\n
\r\n\r\n
\r\n
-
-
-
- \r\n");
-#line 115 "DatabaseErrorPage.cshtml"
- }
-
-#line default
-#line hidden
-
- WriteLiteral("\r\n
");
-#line 117 "DatabaseErrorPage.cshtml"
+ WriteLiteral("\";\r\n applyMigrations.disabled = false;\r\n }\r\n \r\n\r\n
");
+#line 108 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_HowToApplyFromCmd);
#line default
#line hidden
WriteLiteral("
\r\n
");
-#line 118 "DatabaseErrorPage.cshtml"
+#line 109 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_ApplyMigrationsCommand);
#line default
#line hidden
WriteLiteral("\r\n
\r\n
\r\n");
-#line 121 "DatabaseErrorPage.cshtml"
+#line 112 "DatabaseErrorPage.cshtml"
}
else if (Model.PendingModelChanges)
{
@@ -352,31 +282,31 @@ using Microsoft.AspNet.Diagnostics.Entity.Views
#line hidden
WriteLiteral(" \r\n
");
-#line 125 "DatabaseErrorPage.cshtml"
+#line 116 "DatabaseErrorPage.cshtml"
Write(Strings.FormatDatabaseErrorPage_PendingChangesTitle(Model.ContextType.Name));
#line default
#line hidden
WriteLiteral("
\r\n
");
-#line 126 "DatabaseErrorPage.cshtml"
+#line 117 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_PendingChangesInfo);
#line default
#line hidden
WriteLiteral("
\r\n
");
-#line 127 "DatabaseErrorPage.cshtml"
+#line 118 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_AddMigrationCommand);
#line default
#line hidden
WriteLiteral("\r\n
\r\n
");
-#line 129 "DatabaseErrorPage.cshtml"
+#line 120 "DatabaseErrorPage.cshtml"
Write(Strings.DatabaseErrorPage_ApplyMigrationsCommand);
#line default
#line hidden
WriteLiteral("\r\n
\r\n
\r\n");
-#line 132 "DatabaseErrorPage.cshtml"
+#line 123 "DatabaseErrorPage.cshtml"
}
#line default
diff --git a/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cshtml b/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cshtml
index c1f181834f..d6e3b2d065 100644
--- a/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cshtml
+++ b/src/Microsoft.AspNet.Diagnostics.Entity/Views/DatabaseErrorPage.cshtml
@@ -33,17 +33,14 @@
@Strings.DatabaseErrorPage_Title
- @if (Model.Options.ShowExceptionDetails)
- {
-
- @for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
- {
- @ex.GetType().Name: @ex.Message
-
- }
-
-
- }
+
+ @for (Exception ex = Model.Exception; ex != null; ex = ex.InnerException)
+ {
+ @ex.GetType().Name: @ex.Message
+
+ }
+
+
@if (!Model.DatabaseExists && !Model.PendingMigrations.Any())
{
@@ -60,59 +57,53 @@
@Strings.FormatDatabaseErrorPage_PendingMigrationsTitle(Model.ContextType.Name)
@Strings.FormatDatabaseErrorPage_PendingMigrationsInfo(Model.ContextType.Name)
- @if (Model.Options.ListMigrations)
- {
-
- @foreach (var migration in Model.PendingMigrations)
- {
- - @migration
- }
-
- }
+
+ @foreach (var migration in Model.PendingMigrations)
+ {
+ - @migration
+ }
+
- @if (Model.Options.EnableMigrationCommands)
- {
-
-
-
-
-
-
- }
+ var formBody = "context=@JavaScriptEncode(UrlEncode(Model.ContextType.AssemblyQualifiedName))";
+ req.open("POST", "@JavaScriptEncode(Model.Options.MigrationsEndPointPath.Value)", true);
+ req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ req.setRequestHeader("Content-length", formBody.length);
+ req.setRequestHeader("Connection", "close");
+ req.send(formBody);
+ }
+
+ function ErrorApplyingMigrations() {
+ applyMigrations.innerHTML = "@JavaScriptEncode(Strings.DatabaseErrorPage_ApplyMigrationsButton)";
+ applyMigrationsError.innerHTML = "@JavaScriptEncode(Strings.DatabaseErrorPage_ApplyMigrationsFailed)";
+ applyMigrations.disabled = false;
+ }
+
@Strings.DatabaseErrorPage_HowToApplyFromCmd
@Strings.DatabaseErrorPage_ApplyMigrationsCommand
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs
index 951dbc7610..d399e30d2f 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageExtensions.cs
@@ -3,6 +3,7 @@
using System;
using Microsoft.AspNet.Diagnostics;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNet.Builder
{
@@ -23,32 +24,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(app));
}
- return app.UseDeveloperExceptionPage(options => { });
- }
-
- ///
- /// Captures synchronous and asynchronous instances from the pipeline and generates HTML error responses.
- ///
- /// The .
- /// A callback to configure .
- /// A reference to the after the operation has completed.
- public static IApplicationBuilder UseDeveloperExceptionPage(
- this IApplicationBuilder app,
- Action configureOptions)
- {
- if (app == null)
- {
- throw new ArgumentNullException(nameof(app));
- }
-
- if (configureOptions == null)
- {
- throw new ArgumentNullException(nameof(configureOptions));
- }
-
- var options = new DeveloperExceptionPageOptions();
- configureOptions(options);
- return app.UseMiddleware(options);
+ return app.UseMiddleware();
}
///
@@ -71,7 +47,7 @@ namespace Microsoft.AspNet.Builder
throw new ArgumentNullException(nameof(options));
}
- return app.UseMiddleware(options);
+ return app.UseMiddleware(Options.Create(options));
}
}
}
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
index 47133d8724..49044ff8a4 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageMiddleware.cs
@@ -9,10 +9,12 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Diagnostics.Views;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Http;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
using Microsoft.Extensions.PlatformAbstractions;
using StackFrame = Microsoft.AspNet.Diagnostics.Views.StackFrame;
@@ -37,7 +39,7 @@ namespace Microsoft.AspNet.Diagnostics
///
public DeveloperExceptionPageMiddleware(
RequestDelegate next,
- DeveloperExceptionPageOptions options,
+ IOptions options,
ILoggerFactory loggerFactory,
IApplicationEnvironment appEnvironment,
DiagnosticSource diagnosticSource)
@@ -53,9 +55,9 @@ namespace Microsoft.AspNet.Diagnostics
}
_next = next;
- _options = options;
+ _options = options.Value;
_logger = loggerFactory.CreateLogger();
- _fileProvider = options.FileProvider ?? new PhysicalFileProvider(appEnvironment.ApplicationBasePath);
+ _fileProvider = _options.FileProvider ?? new PhysicalFileProvider(appEnvironment.ApplicationBasePath);
_diagnosticSource = diagnosticSource;
}
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs
index a6d112f6bd..bfd10e9eb3 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/DeveloperExceptionPageOptions.cs
@@ -1,9 +1,10 @@
// 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 Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.FileProviders;
-namespace Microsoft.AspNet.Diagnostics
+namespace Microsoft.AspNet.Builder
{
///
/// Options for the .
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
index cd92acb378..62b0ab7979 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorModel.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
+using Microsoft.AspNet.Builder;
namespace Microsoft.AspNet.Diagnostics.Views
{
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs
index 9f1a890bab..95ac56b327 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/CompilationErrorPage.cs
@@ -57,15 +57,13 @@ using Microsoft.AspNet.Diagnostics
#line default
#line hidden
- WriteLiteral("\r\n\r\n \r\n \r\n ");
+ WriteLiteral("\r\n\r\n \r\n \r\n ");
#line 19 "CompilationErrorPage.cshtml"
Write(Resources.ErrorPageHtml_Title);
#line default
#line hidden
- WriteLiteral("\r\n \r\n \r\n \r\n ");
#line 25 "CompilationErrorPage.cshtml"
Write(Resources.ErrorPageHtml_CompilationException);
@@ -360,8 +358,7 @@ WriteAttributeValue("", 2677, frame.Line + 1, 2677, 17, false);
#line default
#line hidden
- WriteLiteral(" \r\n \r\n\r\n");
+ WriteLiteral(" \r\n \r\n\r\n");
}
#pragma warning restore 1998
}
diff --git a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs
index cd00fcff62..e5fc8cc323 100644
--- a/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs
+++ b/src/Microsoft.AspNet.Diagnostics/DeveloperExceptionPage/Views/ErrorPage.cs
@@ -76,15 +76,13 @@ WriteAttributeValue("", 504, CultureInfo.CurrentUICulture.TwoLetterISOLanguageNa
#line default
#line hidden
EndWriteAttribute();
- WriteLiteral(" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n \r\n \r\n ");
+ WriteLiteral(" xmlns=\"http://www.w3.org/1999/xhtml\">\r\n \r\n \r\n ");
#line 25 "ErrorPage.cshtml"
Write(Resources.ErrorPageHtml_Title);
#line default
#line hidden
- WriteLiteral("\r\n \r\n \r\n \r\n ");
#line 31 "ErrorPage.cshtml"
Write(Resources.ErrorPageHtml_UnhandledException);
@@ -213,8 +211,7 @@ WriteAttributeValue("", 1882, firstFrame.File, 1882, 16, false);
#line default
#line hidden
- WriteLiteral("