Asp.Net MVC:在 AuthorizeAttribute 中使用模型绑定器?
我有一个会话变量,它指示我所处的上下文。在此背景下将取决于一些授权。
目前,我有一个会话变量,并在自定义 AuthorizeAttribute 中检查它。效果很好。
但我发现了“ModelBinder”方式,它基本上在会话访问和控制器中使用之间添加了一层。
有没有办法在我的 AuthorizeAttribute 中也使用此 ModelBinder?
谢谢你!
I've a session vars that indicates me in which context I'm. On this contexts will depends some authorization.
Currently, I've a session vars, and I check it in a custom AuthorizeAttribute. It works great.
But I discovered the "ModelBinder" way, which basically adds a layer between between the access to the session and the use in controllers.
Is there a way to also use this ModelBinder in my AuthorizeAttribute?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
否,模型绑定器在授权属性 之后调用OnAuthorization 方法当然假设该方法已授权该请求。但如果您有兴趣检索请求参数,您可以使用
filtyerContext
:No, the model binder is invoked after the authorize attribute OnAuthorization method assuming of course this method has authorized the request. But if you are interested in retrieving request parameters you could use the
filtyerContext
: