c# - asp.net 扩展 IPrincipal

标签 c# inheritance interface iprincipal

我想在 asp.net 中扩展 IPrincipal 以允许我获得我将定义的用户类型。我想在 Controller 中实现这一点

string type = User.UserType 

然后在我的扩展方法中我将有一个类似的方法

public string UserType()
{
  // do some database access 
  return userType

}

我该怎么做?是否可以? 谢谢!

最佳答案

你可以做一个扩展方法:

public static string UserType(this IPrincipal principal) {
    // do some database access 
    return something;
}

关于c# - asp.net 扩展 IPrincipal,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3214520/

相关文章:

java - 在同一列表中返回两个不同的 bean

c# - Windows 窗体、循环和线程

c# - 我的单元测试有什么问题? C#

java - 继承类中的反射

CSS 嵌套 : inherit from whom?

C++ 接口(interface)抛出 Unresolved external symbol 错误

c# - 检查大数是否是有效的 Unicode 字符

c# - Visual Studio C# : How to keep spaces between angle brackets?

c++ - 使用模板基类消除工厂类派生类冗余的简洁方法

指定类型时 javac "uses unchecked or unsafe operations"