Should I call base.OnAuthorization(filterContext)?

ぐ巨炮叔叔 提交于 2019-12-06 13:17:30

The default implementation is open source and can be viewed here.

It checks whether the user is authenticated, then checks to ensure the user or role is specified on the attribute.

I guess the real question is, why are you writing a custom AuthorizeAttribute when the built-in one already does what you are doing?

Do note that it would be simpler to override the AuthorizeCore method (instead of OnAuthorization) if you really do need to customize it because the OnAuthorization method has code to disable output caching so cached views cannot be seen after logout.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!