我遇到了问题而无法找到解决方案。
我有一个模块,其中包含一些IPrincipal的扩展方法:
<System.Runtime.CompilerServices.Extension()> _
Public Function CanCallGhostbusters(ByRef activeUser As IPrincipal) As Boolean
Dim result As Boolean = False
resultado = activeUser.IsInRole("GB\GhostBustersCaller") AndAlso ...
Return result
End Function
代码在.aspx页面中运行良好:
Protected Sub Page_Load(ByVal s As Object, ByVal e As System.EventArgs) Handles Me.Load
If User.CanCallGhostbusters Then
//It works; cool!
End If
End Sub
但它不在主页中工作;扩展方法没有出现在intellisense中。我试过了:
If HttpContext.Current.User.CanCallGhostbusters Then
//Error: CanCallGhostbusters is not a member of System.Security.Principal.IPrincipal
End If
Dim activeUser As System.Security.Principal.IPrincipal = HttpContext.Current.User
If activeUser.CanCallGhostbusters Then
//Error: CanCallGhostbusters is not a member of System.Security.Principal.IPrincipal
End If
有什么想法吗?
谢谢!