.net - What's the purpose of IAuthenticationFilter.OnAuthenticationChallenge() -


i have custom iauthenticationfilter implementation registered in registerglobalfilters(). in project i'm witnessing following call sequence:

  1. iauthenticationfilter.onauthentication
  2. authorization (if any)
  3. controller action
  4. 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?

source

"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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -