|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | | -using System.Reflection; |
5 | 4 | using Microsoft.AspNetCore; |
6 | 5 | using Microsoft.AspNetCore.Http.HttpResults; |
7 | 6 | using Microsoft.AspNetCore.Http.Metadata; |
|
11 | 10 | var builder = WebApplication.CreateBuilder(args); |
12 | 11 | var app = builder.Build(); |
13 | 12 |
|
14 | | -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
15 | | -hostBuilder.Build().Run(); |
16 | | -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed |
| 13 | +string Plaintext() => "Hello, World!"; |
| 14 | +app.MapGet("/plaintext", Plaintext); |
17 | 15 |
|
18 | | -Func<IDictionary<string, object>, Task> ConfigureOwinPipeline(Func<IDictionary<string, object>, Task> next) => env => |
| 16 | +app.MapGet("/", () => $""" |
| 17 | + Operating System: {Environment.OSVersion} |
| 18 | + .NET version: {Environment.Version} |
| 19 | + Username: {Environment.UserName} |
| 20 | + Date and Time: {DateTime.Now} |
| 21 | + """); |
| 22 | + |
| 23 | +app.UseOwin(pipeline => |
19 | 24 | { |
20 | | - return next(env); |
21 | | -}; |
| 25 | + pipeline(next => |
| 26 | + { |
| 27 | + return async environment => |
| 28 | + { |
| 29 | + // if you want to get OWIN environment properties |
| 30 | + //if (environment is OwinEnvironment owin) |
| 31 | + //{ |
| 32 | + // foreach (var prop in owin) |
| 33 | + // { |
| 34 | + // app.Logger.LogInformation($"{prop.Key} - {prop.Value}"); |
| 35 | + // } |
| 36 | + //} |
| 37 | + |
| 38 | + await next(environment); |
| 39 | + }; |
| 40 | + }); |
| 41 | +}); |
| 42 | + |
| 43 | +app.Run(); |
0 commit comments