更新时间:2023-02-25 22:51:20
使用这个方法来保存本金,所以它也建立在跟帖:
Use this method to save the principal, so it sets up also in the thread:
private void SetPrincipal(IPrincipal principal)
{
Thread.CurrentPrincipal = principal;
if (HttpContext.Current != null)
{
HttpContext.Current.User = principal;
}
}
更新:也允许匿名和测试,如果User.IsInRole越来越方法内在的东西。
Update: Also allow anonymous and test if User.IsInRole is getting something inside the method.