ASP.NET MVC 2 如何在执行操作之前检查用户的权限?
我有一个控制器,要调用其所有操作,用户必须拥有执行此操作的权限。问题是如何在执行操作之前检查这一点? 如果用户没有权限,我想渲染一个带有错误消息的视图。我尝试使用重写的 OnActionExecuting
方法,但我无法从中返回视图方法
I have a controller, and to invoke all its actions the user has to have privilages to do that. The question is how to check that before action is executed? If the user doesn't have permissions I want to render a View with error message. I tried to use overriden OnActionExecuting
method, but I can't return a View from that method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上,您可以:
As a matter of fact you can:
在类 Controller 中,此方法受到保护。
In the class Controller this method is protected.