Skip to content

Commit 3a25701

Browse files
Provide Microsoft.AspNetCore.Owin package README (dotnet#57816)
1 parent d0675b5 commit 3a25701

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

src/Http/Owin/src/PACKAGE.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## About
2+
3+
`Microsoft.AspNetCore.Owin` provides adapters for running OWIN middleware in an ASP.NET Core application, and to run ASP.NET Core middleware in an OWIN application.
4+
5+
## How to Use
6+
7+
To use `Microsoft.AspNetCore.Owin`, follow these steps:
8+
9+
### Installation
10+
11+
```shell
12+
dotnet add package Microsoft.AspNetCore.Owin
13+
```
14+
15+
### Configuration
16+
17+
To use OWIN middleware in an ASP.NET Core pipeline:
18+
1. Define the OWIN middleware, if not done already. Here's a basic "Hello World" example:
19+
```csharp
20+
public Task OwinHello(IDictionary<string, object> environment)
21+
{
22+
var responseText = "Hello World via OWIN";
23+
var responseBytes = Encoding.UTF8.GetBytes(responseText);
24+
25+
// OWIN Environment Keys: https://owin.org/spec/spec/owin-1.0.0.html
26+
var responseStream = (Stream)environment["owin.ResponseBody"];
27+
var responseHeaders = (IDictionary<string, string[]>)environment["owin.ResponseHeaders"];
28+
29+
responseHeaders["Content-Length"] = [responseBytes.Length.ToString(CultureInfo.InvariantCulture)];
30+
responseHeaders["Content-Type"] = ["text/plain"];
31+
32+
return responseStream.WriteAsync(responseBytes, 0, responseBytes.Length);
33+
}
34+
```
35+
2. Add the middleware to the ASP.NET Core pipeline with the `UseOwin` extension method. For example:
36+
```csharp
37+
app.UseOwin(pipeline =>
38+
{
39+
pipeline(next => OwinHello);
40+
});
41+
```
42+
43+
## Additional Documentation
44+
45+
For additional documentation, including examples on running ASP.NET Core on an OWIN-based server, refer to the [official documentation](https://learn.microsoft.com/aspnet/core/fundamentals/owin) on OWIN with ASP.NET Core.
46+
47+
## Feedback &amp; Contributing
48+
49+
`Microsoft.AspNetCore.Owin` is released as open-source under the [MIT license](https://licenses.nuget.org/MIT). Bug reports and contributions are welcome at [the GitHub repository](https://github.com/dotnet/aspnetcore).

0 commit comments

Comments
 (0)