我有基本控制器,假设它有一个名为AnyProperty
:
public class MyBaseController : Controller
{
public MyObject AnyProperty { get; set; }
public MyBaseController()
{
AnyProperty = new MyObject();
}
}
在RoleAttribute
我需要使用AnyProperty
. 我用
public class RoleAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
MyBaseController controllerInstance = new MyBaseController();
controllerInstance.AnyProperty // I use like this
}
}
我怎样才能得到我的AnyProperty
财产 httpContext
?不使用MyBaseController
实例。可能吗?