Skip to content

Commit 8cd24a2

Browse files
committed
init the owin sample
1 parent be3c7d4 commit 8cd24a2

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed
Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Reflection;
54
using Microsoft.AspNetCore;
65
using Microsoft.AspNetCore.Http.HttpResults;
76
using Microsoft.AspNetCore.Http.Metadata;
@@ -11,11 +10,34 @@
1110
var builder = WebApplication.CreateBuilder(args);
1211
var app = builder.Build();
1312

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);
1715

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 =>
1924
{
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

Comments
 (0)