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.
更多推荐
发布评论