Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Is Owin supported with MVC6

$
0
0

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.

http://brockallen.com/2013/10/24/a-primer-on-owin-cookie-authentication-middleware-for-the-asp-net-developer/#comment-35481

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.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>