using Microsoft.Owin; using System.Web; public class ExampleController : Controller { public ActionResult Index() { var owinContext = HttpContext.GetOwinContext(); if (owinContext.Authentication.User.Identity.IsAuthenticated) { // perform actions for authenticated user } else { // perform actions for unauthenticated user } return View(); } }
using Microsoft.Owin; using System.Web; using System.Web.Mvc; public class ExampleController : Controller { public ActionResult Index() { var owinContext = HttpContext.GetOwinContext(); var requestHeaders = owinContext.Request.Headers; var userAgent = requestHeaders["User-Agent"]; return View("Index", userAgent); } }In this example, the OWIN context is retrieved using the GetOwinContext method and then used to retrieve the user agent header from the request. This value is then passed to the view via the Index action result. The Microsoft.Owin package library is used to reference the OWIN namespace.