Skip to content

Commit feb3d63

Browse files
authored
Remove application error (#25882)
1 parent 8725e2a commit feb3d63

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

src/Servers/IIS/IIS/src/Core/IISHttpContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ protected async Task FireOnCompleted()
533533
}
534534
catch (Exception ex)
535535
{
536-
ReportApplicationError(ex);
536+
Log.ApplicationError(_logger, ((IHttpConnectionFeature)this).ConnectionId, TraceIdentifier, ex);
537537
}
538538
}
539539
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,26 @@ public async Task EnvironmentVariableForLauncherArgsIsPreferred(HostingModel hos
968968
await StartAsync(deploymentParameters);
969969
}
970970

971+
[ConditionalFact]
972+
[RequiresNewHandler]
973+
[MaximumOSVersion(OperatingSystems.Windows, WindowsVersions.Win10_20H1, SkipReason = "Shutdown hangs https://github.com/dotnet/aspnetcore/issues/25107")]
974+
public async Task OnCompletedDoesNotFailRequest()
975+
{
976+
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
977+
var deploymentResult = await DeployAsync(deploymentParameters);
978+
979+
var response = await deploymentResult.HttpClient.GetAsync("/OnCompletedThrows");
980+
Assert.True(response.IsSuccessStatusCode);
981+
982+
StopServer();
983+
984+
if (deploymentParameters.ServerType == ServerType.IISExpress)
985+
{
986+
// We can't read stdout logs from IIS as they aren't redirected.
987+
Assert.Contains(TestSink.Writes, context => context.Message.Contains("An unhandled exception was thrown by the application."));
988+
}
989+
}
990+
971991
private static void VerifyDotnetRuntimeEventLog(IISDeploymentResult deploymentResult)
972992
{
973993
var entries = GetEventLogsFromDotnetRuntime(deploymentResult);

src/Servers/IIS/IIS/test/testassets/InProcessWebSite/Startup.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,16 @@ public Task IncreaseRequestLimit(HttpContext httpContext)
14611461
return Task.CompletedTask;
14621462
}
14631463

1464+
public Task OnCompletedThrows(HttpContext httpContext)
1465+
{
1466+
httpContext.Response.OnCompleted(() =>
1467+
{
1468+
throw new Exception();
1469+
});
1470+
1471+
return Task.CompletedTask;
1472+
}
1473+
14641474
internal static readonly HashSet<(string, StringValues, StringValues)> NullTrailers = new HashSet<(string, StringValues, StringValues)>()
14651475
{
14661476
("NullString", (string)null, (string)null),

0 commit comments

Comments
 (0)