Remove the DeveloperExceptionPage middleware from WebHost.CreateDefaultBuilder:

- The templates still have it explicitly and it's best to have middleware added by the app directly
This commit is contained in:
damianedwards 2017-05-02 22:32:31 -07:00 committed by Damian Edwards
parent eb09fc7dd4
commit 4d5e1076c9
4 changed files with 0 additions and 36 deletions

View File

@ -188,7 +188,6 @@ namespace Microsoft.AspNetCore
})
.ConfigureServices(services =>
{
services.AddSingleton<IStartupFilter, WebHostStartupFilter>();
services.AddTransient<IConfigureOptions<KestrelServerOptions>, KestrelServerOptionsSetup>();
});

View File

@ -1,26 +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.
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace Microsoft.AspNetCore
{
internal class WebHostStartupFilter : IStartupFilter
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
var env = app.ApplicationServices.GetService<IHostingEnvironment>();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
next(app);
};
}
}
}

View File

@ -54,10 +54,8 @@ namespace Microsoft.AspNetCore.Tests
await ExecuteTestApp(applicationName, async (deploymentResult, logger) =>
{
var response = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync(string.Empty), logger, deploymentResult.HostShutdownToken);
var errorResponse = await RetryHelper.RetryRequest(() => deploymentResult.HttpClient.GetAsync("/error"), logger, deploymentResult.HostShutdownToken);
var responseText = await response.Content.ReadAsStringAsync();
var errorResponseText = await errorResponse.Content.ReadAsStringAsync();
try
{
// Assert server is Kestrel
@ -65,9 +63,6 @@ namespace Microsoft.AspNetCore.Tests
// The application name will be sent in response when all asserts succeed in the test app.
Assert.Equal(applicationName, responseText);
// Assert UseDeveloperExceptionPage is called in WebHostStartupFilter.
Assert.Contains("An unhandled exception occurred while processing the request.", errorResponseText);
}
catch (XunitException)
{

View File

@ -30,10 +30,6 @@ namespace CreateDefaultBuilderApp
})
.Configure(app =>
{
app.Map("/error", subApp =>
{
subApp.Run(context => throw new Exception());
});
app.Run(context =>
{
return context.Response.WriteAsync(responseMessage);