简体   繁体   English

C#变量属性

[英]C# variable attributes

I am developing a web application with ASP.NET MVC.我正在使用 ASP.NET MVC 开发 Web 应用程序。 I need to authorize users in two different ways now, so I had to adjust some thing in my Controllers.我现在需要以两种不同的方式授权用户,所以我不得不在我的控制器中调整一些东西。

One of the things was to change the annotation of the Controller from [Authorize] to [AllowAnonymous] .其中一件事是将 Controller 的注释从[Authorize]更改为[AllowAnonymous] The reason why I need two different ways to authorize my users, is because some of the users will use a different kind of authorization.我之所以需要两种不同的方式来授权我的用户,是因为有些用户会使用不同类型的授权。

What is the best solution for this?什么是最好的解决方案? I would like to have some kind of config file that I will lookup, before the start.在开始之前,我想要一些我将查找的配置文件。

创建一个动作过滤器并尝试实现您的授权逻辑(两种不同类型的授权)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM