-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Update debug code to not use Startup /2 #35339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d0a695e
Update debug code to not use Startup /2
Rick-Anderson c86de1c
Update debug code to not use Startup /2
Rick-Anderson 5ceb4b7
Update debug code to not use Startup /2
Rick-Anderson 4d4fbc2
Update debug code to not use Startup /2
Rick-Anderson 7fedeb4
Update debug code to not use Startup /2
Rick-Anderson 1b40747
Update debug code to not use Startup /2
Rick-Anderson f6e9201
Update debug code to not use Startup /2
Rick-Anderson e48b667
Update debug code to not use Startup /2
Rick-Anderson 631a4e1
Update debug code to not use Startup /2
Rick-Anderson 74464ea
Apply suggestions from code review
Rick-Anderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| using Microsoft.AspNetCore.Authentication; | ||
| using Microsoft.AspNetCore.Http.Features; | ||
| using Microsoft.AspNetCore.Server.IISIntegration; | ||
| using System.Text; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
| builder.Services.AddAuthentication(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| app.MapGet("/", () => "Hello World!"); | ||
|
|
||
| if (app.Environment.IsDevelopment()) | ||
| { | ||
| app.Run(async (context) => | ||
| { | ||
| var sb = new StringBuilder(); | ||
| var nl = System.Environment.NewLine; | ||
| var rule = string.Concat(nl, new string('-', 40), nl); | ||
|
|
||
|
|
||
| var authSchemeProvider = app.Services. | ||
| GetRequiredService<IAuthenticationSchemeProvider>(); | ||
|
|
||
| sb.Append($"Request{rule}"); | ||
| sb.Append($"{DateTimeOffset.Now}{nl}"); | ||
| sb.Append($"{context.Request.Method} {context.Request.Path}{nl}"); | ||
| sb.Append($"Scheme: {context.Request.Scheme}{nl}"); | ||
| sb.Append($"Host: {context.Request.Headers["Host"]}{nl}"); | ||
| sb.Append($"PathBase: {context.Request.PathBase.Value}{nl}"); | ||
| sb.Append($"Path: {context.Request.Path.Value}{nl}"); | ||
| sb.Append($"Query: {context.Request.QueryString.Value}{nl}{nl}"); | ||
|
|
||
| sb.Append($"Connection{rule}"); | ||
| sb.Append($"RemoteIp: {context.Connection.RemoteIpAddress}{nl}"); | ||
| sb.Append($"RemotePort: {context.Connection.RemotePort}{nl}"); | ||
| sb.Append($"LocalIp: {context.Connection.LocalIpAddress}{nl}"); | ||
| sb.Append($"LocalPort: {context.Connection.LocalPort}{nl}"); | ||
| sb.Append($"ClientCert: {context.Connection.ClientCertificate}{nl}{nl}"); | ||
|
|
||
| sb.Append($"Identity{rule}"); | ||
| sb.Append($"User: {context.User.Identity.Name}{nl}"); | ||
| var scheme = await authSchemeProvider | ||
| .GetSchemeAsync(IISDefaults.AuthenticationScheme); | ||
| sb.Append($"DisplayName: {scheme?.DisplayName}{nl}{nl}"); | ||
|
|
||
| sb.Append($"Headers{rule}"); | ||
| foreach (var header in context.Request.Headers) | ||
| { | ||
| sb.Append($"{header.Key}: {header.Value}{nl}"); | ||
| } | ||
| sb.Append(nl); | ||
|
|
||
| sb.Append($"WebSockets{rule}"); | ||
| if (context.Features.Get<IHttpUpgradeFeature>() != null) | ||
| { | ||
| sb.Append($"Status: Enabled{nl}{nl}"); | ||
| } | ||
| else | ||
| { | ||
| sb.Append($"Status: Disabled{nl}{nl}"); | ||
| } | ||
|
|
||
| sb.Append($"Configuration{rule}"); | ||
| var config = builder.Configuration; | ||
|
|
||
| foreach (var pair in config.AsEnumerable()) | ||
| { | ||
| sb.Append($"{pair.Key}: {pair.Value}{nl}"); | ||
| } | ||
| sb.Append(nl); | ||
| sb.Append(nl); | ||
|
|
||
| sb.Append($"Environment Variables{rule}"); | ||
| var vars = System.Environment.GetEnvironmentVariables(); | ||
| foreach (var key in vars.Keys.Cast<string>().OrderBy(key => key, | ||
| StringComparer.OrdinalIgnoreCase)) | ||
| { | ||
| var value = vars[key]; | ||
| sb.Append($"{key}: {value}{nl}"); | ||
| } | ||
|
|
||
| context.Response.ContentType = "text/plain"; | ||
| await context.Response.WriteAsync(sb.ToString()); | ||
| }); | ||
| } | ||
|
|
||
| app.Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*" | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.