i've added these usings , have nuget packages installed. why can not use claim? visual studio says claimsidentity, claim , claimtypes not found.
~/controllers/acccontroller.cs
using microsoft.aspnet.identity; using microsoft.owin.security; using system.threading.tasks; using system.web; using system.web.mvc; namespace myproject.controllers { public class acccontroller : controller { [allowanonymous] [httppost] public actionresult login(loginmodel model) { if (!modelstate.isvalid) { return view(); } // don't in production! if (model.email == "admin@admin.com" && model.password == "password") { var identity = new claimsidentity(new[] { new claim(claimtypes.name, "ben"), new claim(claimtypes.email, "a@b.com"), new claim(claimtypes.country, "england") }, "applicationcookie"); var ctx = request.getowincontext(); var authmanager = ctx.authentication; authmanager.signin(identity); return redirect(getredirecturl(model.returnurl)); } // user authn failed modelstate.addmodelerror("", "invalid email or password"); return view(); } } }
try add in code:
using system.security.claims;