.net - What's the purpose of IAuthenticationFilter.OnAuthenticationChallenge() -
i have custom iauthenticationfilter implementation registered in registerglobalfilters()
. in project i'm witnessing following call sequence:
- iauthenticationfilter.onauthentication
- authorization (if any)
- controller action
- iauthenticationfilter.onauthenticationchallenge
why happen after controller action? this blog post read
the key thing remember
onauthenticationchallenge
not run before every other action filter. can run @ various stages.
how can useful if can't tell when called?
"the onauthenticationchallange method called mvc framework whenever request has failed authentication or authorization policies action method. onauthenticationchallenge method passed authenticationchallengecontext object, derived controllercontext class"
so, practical example be:
1 - set custom authorize filter
2 - users fails on authorizing method
3 - onauthenticationchallenge method called.
Comments
Post a Comment