限制 IIS 中对 MVC 路由的访问

发布于 2024-12-12 13:33:18 字数 353 浏览 5 评论 0原文

我想将通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

假情假意假温柔 2024-12-19 13:33:18

坚持使用授权属性以获得最佳实践。授权规则的问题在于它是基于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文