ASP.NET MVC:如何为用户或客户端IP授权?(ASP.NET MVC: how to authorize for users or client IP?)

编程入门 行业动态 更新时间:2024-10-23 16:15:56
ASP.NET MVC:如何为用户或客户端IP授权?(ASP.NET MVC: how to authorize for users or client IP?)

在ASP.NET MVC应用程序中,我希望某些控制器只能由授权用户访问。 AuthorizeAttribute非常适用于此。 但是,即使远程用户未经授权,我也希望这些控制器能够访问某些IP号码。 我应该覆盖AuthorizeAttribute以提供此功能,还是有更好的解决方案?

In an ASP.NET MVC application, I'd like for certain controllers to only be accessible to authorized users. AuthorizeAttribute works great for this. However, I'd also like those controllers to provide access to certain IP numbers even if the remote user is unauthorized. Should I override AuthorizeAttribute to provide this functionality, or is there a better solution?

最满意答案

你的直觉是正确的 - 在这种情况下,扩展授权属性最有意义。

Your instincts are correct--extending authorize attribute makes the most sense in this case.

更多推荐

本文发布于:2023-04-28 00:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329670.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:何为   客户端   用户   MVC   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!