asp.net扩展IPrincipal [英] asp.net extending IPrincipal

查看:88
本文介绍了asp.net扩展IPrincipal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在asp.net中扩展IPrincipal,以允许我获得将要定义的用户类型.我想在控制器中做到这一点

I would like to extend IPrincipal in asp.net to allow me to get the usertype that I will define. I would like to make it possible to do this in a controller

string type = User.UserType 

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

then in my extension method i will have a method like

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

}

我该怎么做?是否有可能? 谢谢!

how can I do this? is it possible? Thanks!

推荐答案

您可以创建扩展方法:

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

这篇关于asp.net扩展IPrincipal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆