ASP.NET Core component for running OWIN middleware in an ASP.NET Core application, and to run ASP.NET Core middleware in an OWIN application. This package was built from the source code at https://github.com/dotnet/dotnet/tree/87bc0b04e21d786669142109a5128c95618b75ed
$ dotnet add package Microsoft.AspNetCore.OwinMicrosoft.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.
To use Microsoft.AspNetCore.Owin, follow these steps:
dotnet add package Microsoft.AspNetCore.Owin
To use OWIN middleware in an ASP.NET Core pipeline:
public Task OwinHello(IDictionary<string, object> environment)
{
var responseText = "Hello World via OWIN";
var responseBytes = Encoding.UTF8.GetBytes(responseText);
// OWIN Environment Keys: https://owin.org/spec/spec/owin-1.0.0.html
var responseStream = (Stream)environment["owin.ResponseBody"];
var responseHeaders = (IDictionary<string, string[]>)environment["owin.ResponseHeaders"];
responseHeaders["Content-Length"] = [responseBytes.Length.ToString(CultureInfo.InvariantCulture)];
responseHeaders["Content-Type"] = ["text/plain"];
return responseStream.WriteAsync(responseBytes, 0, responseBytes.Length);
}
UseOwin extension method. For example:
app.UseOwin(pipeline =>
{
pipeline(next => OwinHello);
});
For additional documentation, including examples on running ASP.NET Core on an OWIN-based server, refer to the official documentation on OWIN with ASP.NET Core.
Microsoft.AspNetCore.Owin is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.