cookies - Asp.net core 2.0 services.AddCookieAuthentication event OnValidatePrincipal -




recently stumble upon problem seems hard solve. trying mangage new mvc6 core in windows environment. 2.0 preview2 release. problem want subscribe onvalidateprincipal in

services.addcookieauthentication( o => { ... o.events = new cookieauthenticationevents {     onvalidateprincipal = principalvalidator.validateasync }; 

}); created class suggested in doc here in same file without namespace like:

 public static class principalvalidator {     public override async task validateasync(cookievalidateprincipalcontext context)     {         string usersessiontoken  = context.principal.claims.firstordefault(x => x.type == claimtypes.name)?.value;         if (usersessiontoken  == null)         {             context.rejectprincipal();             await context.httpcontext.authentication.signoutasync(cookieauthenticationdefaults.authenticationscheme);         }     } } 

so .. problem when try compile receive 2 errors :

  1. relative line onvalidateprincipal = principalvalidator.validateasync error "an object reference required non-static field, method, or property 'principalvalidator.validateasync(cookievalidateprincipalcontext)"

  2. relative line public override async task validateasync(cookievalidateprincipalcontext context) error "validator.validateasync(cookievalidateprincipalcontext)': no suitable method found override"

  3. i add references using microsoft.aspnetcore.http; , using microsoft.aspnetcore.authentication.cookies;

what's wrong in code ?? ; missing reference ?? or correct way override validateasync method in current release ??

hope , thanks





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -