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

how to do identity based authorization in asp.net5 (vnext)

$
0
0

I have 2 pages in my application - Login and Books Listing (for a moment books data is already entered into database). What I want to do is adding a claim after successful login and  I should we able to use that claim in my bookscontroller page to put condition based on the claim.

To add claim - I am writing the following code, but I am not able to find some of the class reference (classes are mentioned in bold).

var claims = new List<Claim>();

claims.Add(new Claim(ClaimTypes.WindowsAccountName, Environment.UserName));

claims.Add(new Claim(ClaimTypes.Email, model.Email));
var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(identity);

This same code works with ASP.Net4 template. Please help.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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