我有一个问题,我找不到解决方案。
我有一个带有 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
但它在母版页中不起作用;扩展方法不会出现在智能感知中。我努力了:
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
任何想法?
谢谢!