I am migrating an old .net web application to MVC6. The old code already has the database designed with roles/permissions and it is working fine, so I do not want to use default MVC6 authentication.
I am trying to do owin implementation to store claims and use for authorization in controller actions. I followed the below post for implementation.
But I can't get reference of DefaultAuthenticationTypes and GetOwinContext() from the below line.
var claims = new List<Claim>();
claims.Add(new Claim(ClaimTypes.Name, "Brock"));
claims.Add(new Claim(ClaimTypes.Email, "brockallen@gmail.com"));
claims.Add(new Claim("whatever", "whynot"));
var id = new ClaimsIdentity(claims,
DefaultAuthenticationTypes.ApplicationCookie);
var ctx = Request.GetOwinContext();
var authenticationManager = ctx.Authentication;
authenticationManager.SignIn(id);
To get reference of DefaultAuthenticationTypes, I installed Microsoft.AspNet.Identity.core from Nuget, but this resulted in lot of other conflicting errors because many methods are matching with the methods of Microsoft.AspNet.Identity (which is by default referenced in project).
Similarly I installed "Microsoft.Owin.Host.SystemWeb" for the reference of "GetOwinContext"but it is also not working.
This code woks perfectly fine in MVC5. Please guide how I can solve this, I am badly stuck.