限制 IIS 中对 MVC 路由的访问
我想将通过 IIS 对 MVC 站点中的路由的访问限制为使用 Windows 身份验证的 Intranet 站点。
我知道这可以通过控制器或操作上的授权属性来完成,但我更喜欢使用 IIS 7.5 的授权规则功能,这样 GUI(inet 管理器)为管理员提供了授予/限制访问权限的能力一个临时的基础。这可能吗?
例如,在默认路由配置中锁定 http://server/admin (通过 Windows 身份验证进行身份验证),而不添加授权属性到 AdminController 类或 AdminController 的索引操作,但只能通过 IIS 管理器部署后。
I'd like to restrict access to the routes in an MVC site via IIS to an intranet site using Windows Authentication.
I'm aware this can be done via the Authorize attribute on a controller or action but I'd prefer to use the Authorization Rules feature of IIS 7.5 such that a GUI (inet manager) provides admins with the ability to grant/restrict access on an adhoc basis. Is this possible?
e.g. in a default routing configuration lock down http://server/admin (which is authenticated with Windows Authentication) without adding an Authorize attribute to the AdminController class or AdminController's Index action but only via the IIS Manager post deploy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
坚持使用授权属性以获得最佳实践。授权规则的问题在于它是基于 URL 的,并且在 MVC 中,多个 url 有时可以到达同一个位置,这就是为什么建议您尽可能在控制器级别进行保护,而不是通过 URL 进行保护。
Stick to the authorize attribute for best practices. The problem with Authorization Rules is that it is URL based and in MVC multiple urls can at times go to the same place that's why it's recommended you secure at the controller level if possible and not via URL.