Skip to content

Commit 5ceb4b7

Browse files
committed
Update debug code to not use Startup /2
1 parent c86de1c commit 5ceb4b7

File tree

4 files changed

+79
-0
lines changed

4 files changed

+79
-0
lines changed

aspnetcore/test/troubleshoot.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,85 @@ To obtain the environment, use either of the following approaches:
8585

8686
:::code language="csharp" source="~/test/troubleshoot/code/9.x/Program.cs" id="snippet1" highlight="13-85":::
8787

88+
<!--
89+
```csharp
90+
if (app.Environment.IsDevelopment())
91+
{
92+
app.Run(async (context) =>
93+
{
94+
var sb = new StringBuilder();
95+
var nl = System.Environment.NewLine;
96+
var rule = string.Concat(nl, new string('-', 40), nl);
97+
98+
99+
var authSchemeProvider = app.Services.GetRequiredService<IAuthenticationSchemeProvider>();
100+
101+
sb.Append($"Request{rule}");
102+
sb.Append($"{DateTimeOffset.Now}{nl}");
103+
sb.Append($"{context.Request.Method} {context.Request.Path}{nl}");
104+
sb.Append($"Scheme: {context.Request.Scheme}{nl}");
105+
sb.Append($"Host: {context.Request.Headers["Host"]}{nl}");
106+
sb.Append($"PathBase: {context.Request.PathBase.Value}{nl}");
107+
sb.Append($"Path: {context.Request.Path.Value}{nl}");
108+
sb.Append($"Query: {context.Request.QueryString.Value}{nl}{nl}");
109+
110+
sb.Append($"Connection{rule}");
111+
sb.Append($"RemoteIp: {context.Connection.RemoteIpAddress}{nl}");
112+
sb.Append($"RemotePort: {context.Connection.RemotePort}{nl}");
113+
sb.Append($"LocalIp: {context.Connection.LocalIpAddress}{nl}");
114+
sb.Append($"LocalPort: {context.Connection.LocalPort}{nl}");
115+
sb.Append($"ClientCert: {context.Connection.ClientCertificate}{nl}{nl}");
116+
117+
sb.Append($"Identity{rule}");
118+
sb.Append($"User: {context.User.Identity.Name}{nl}");
119+
var scheme = await authSchemeProvider
120+
.GetSchemeAsync(IISDefaults.AuthenticationScheme);
121+
sb.Append($"DisplayName: {scheme?.DisplayName}{nl}{nl}");
122+
123+
sb.Append($"Headers{rule}");
124+
foreach (var header in context.Request.Headers)
125+
{
126+
sb.Append($"{header.Key}: {header.Value}{nl}");
127+
}
128+
sb.Append(nl);
129+
130+
sb.Append($"WebSockets{rule}");
131+
if (context.Features.Get<IHttpUpgradeFeature>() != null)
132+
{
133+
sb.Append($"Status: Enabled{nl}{nl}");
134+
}
135+
else
136+
{
137+
sb.Append($"Status: Disabled{nl}{nl}");
138+
}
139+
140+
sb.Append($"Configuration{rule}");
141+
var config = builder.Configuration;
142+
143+
foreach (var pair in config.AsEnumerable())
144+
{
145+
sb.Append($"{pair.Key}: {pair.Value}{nl}");
146+
}
147+
sb.Append(nl);
148+
sb.Append(nl);
149+
150+
sb.Append($"Environment Variables{rule}");
151+
var vars = System.Environment.GetEnvironmentVariables();
152+
foreach (var key in vars.Keys.Cast<string>().OrderBy(key => key,
153+
StringComparer.OrdinalIgnoreCase))
154+
{
155+
var value = vars[key];
156+
sb.Append($"{key}: {value}{nl}");
157+
}
158+
159+
context.Response.ContentType = "text/plain";
160+
await context.Response.WriteAsync(sb.ToString());
161+
});
162+
}
163+
```
164+
--->
165+
166+
88167
## Debug ASP.NET Core apps
89168

90169
The following links provide information on debugging ASP.NET Core apps.
File renamed without changes.
File renamed without changes.

aspnetcore/test/troubleshoot/code/5.x/appsettings.json renamed to aspnetcore/test/troubleshoot/code/9.x/appsettings.json

File renamed without changes.

0 commit comments

Comments
 (0)