var context = new OwinContext(); var authentication = context.Get(typeof(AuthenticationMiddleware).FullName); if (authentication != null) { // Perform authentication operations }
var context = new OwinContext(); var session = context.GetIn this example, GetFeature is used to retrieve the SessionMiddleware feature from the OwinContext. This can be used to access session data stored for the current user, such as reading a session value or setting a new value. Package Library: The IOwinContext interface is part of the Microsoft.Owin.Abstractions package library, which provides a set of interfaces for OWIN components. The other packages that may be required for some features accessed through GetFeature include Microsoft.Owin.Security, Microsoft.Owin.Security.Cookies, and Microsoft.Owin.Session.(typeof(SessionMiddleware).FullName); if(session != null) { // Access session data var value = session.Session["key"]; session.Session["key"] = "new value"; }