Skip to content

Commit 760b809

Browse files
committed
nits
1 parent 22fc50e commit 760b809

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,14 @@ public void Configure(IApplicationBuilder app)
117117

118118
public static void Main(string[] args)
119119
{
120-
throw new Exception();
121-
//var host = new WebHostBuilder()
122-
// .UseKestrel()
123-
// .UseIIS()
124-
// .UseIISIntegration()
125-
// .UseStartup<Startup>()
126-
// .Build();
127-
128-
//host.Run();
120+
var host = new WebHostBuilder()
121+
.UseKestrel()
122+
.UseIIS()
123+
.UseIISIntegration()
124+
.UseStartup<Startup>()
125+
.Build();
126+
127+
host.Run();
129128
}
130129
}
131130
}

src/Servers/IIS/IIS/src/StartupHook.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
using Microsoft.Extensions.FileProviders;
1919
using Microsoft.Extensions.StackTrace.Sources;
2020

21+
22+
/// <summary>
23+
/// Startup hooks are pieces of code that will run before a users program main executes
24+
/// See: https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/host-startup-hook.md
25+
/// The type must be named StartupHook without any namespace, and should be internal.
26+
/// </summary>
2127
internal class StartupHook
2228
{
2329
/// <summary>
@@ -33,10 +39,21 @@ public static void Initialize()
3339
return;
3440
}
3541

36-
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("Development", StringComparison.OrdinalIgnoreCase) ||
37-
Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT").Equals("Development", StringComparison.OrdinalIgnoreCase))
42+
var detailedErrors = Environment.GetEnvironmentVariable("ASPNETCORE_DETAILEDERRORS");
43+
var detailedErrorsEnabled = string.IsNullOrEmpty(detailedErrors) ?
44+
false :
45+
detailedErrors.Equals("1", StringComparison.OrdinalIgnoreCase) ||
46+
detailedErrors.Equals("true", StringComparison.OrdinalIgnoreCase);
47+
48+
var aspnetCoreEnvironment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
49+
var aspnetCoreEnvironmentDevelopment = string.IsNullOrEmpty(aspnetCoreEnvironment) ? false : aspnetCoreEnvironment.Equals("Development", StringComparison.OrdinalIgnoreCase);
50+
51+
var dotnetEnvironment = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT");
52+
var dotnetEnvironmentDevelopment = string.IsNullOrEmpty(dotnetEnvironment) ? false : dotnetEnvironment.Equals("Development", StringComparison.OrdinalIgnoreCase);
53+
54+
if (!detailedErrorsEnabled && !aspnetCoreEnvironmentDevelopment && !dotnetEnvironmentDevelopment)
3855
{
39-
// Not running in development.
56+
// Not running in development or detailed errors aren't enabled
4057
return;
4158
}
4259

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,14 +575,18 @@ public async Task StartupIsSuspendedWhenEventIsUsed()
575575
await request;
576576
}
577577

578-
[ConditionalFact]
578+
[ConditionalTheory]
579579
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
580580
[RequiresNewHandler]
581-
public async Task ExceptionIsLoggedToEventLogAndPutInResponseWhenDeveloperExceptionPageIsEnabled()
581+
[InlineData("ASPNETCORE_ENVIRONMENT", "Development")]
582+
[InlineData("DOTNET_ENVIRONMENT", "deVelopment")]
583+
[InlineData("ASPNETCORE_DETAILED_ERRORS", "1")]
584+
[InlineData("ASPNETCORE_DETAILED_ERRORS", "TRUE")]
585+
public async Task ExceptionIsLoggedToEventLogAndPutInResponseWhenDeveloperExceptionPageIsEnabled(string environmentVariable, string value)
582586
{
583587
var deploymentParameters = Fixture.GetBaseDeploymentParameters();
584588
deploymentParameters.TransformArguments((a, _) => $"{a} Throw");
585-
deploymentParameters.EnvironmentVariables["ASPNETCORE_ENVIRONMENT"] = "Development";
589+
deploymentParameters.EnvironmentVariables[environmentVariable] = value;
586590
var deploymentResult = await DeployAsync(deploymentParameters);
587591
var result = await deploymentResult.HttpClient.GetAsync("/");
588592
Assert.False(result.IsSuccessStatusCode);

0 commit comments

Comments
 (0)