官术网_书友最值得收藏!

Setting the principal

If the application has the custom authentication logic implemented, then we must set the principal in two places:

  • Thread.CurrentPrincipal is the standard way to set the thread's principal in .NET.
  • HttpContext.Current.User is specific to ASP.NET.

The following code shows setting up the principal:

private void SetPrincipal(IPrincipal principal)
{
    Thread.CurrentPrincipal = principal;
    if (HttpContext.Current != null)
    {
        HttpContext.Current.User = principal;
    }
}
主站蜘蛛池模板: 新民市| 永济市| 饶河县| 金乡县| 襄垣县| 海林市| 新丰县| 滦平县| 即墨市| 武乡县| 阳原县| 昭平县| 中超| 香格里拉县| 白水县| 惠东县| 铁岭市| 新平| 龙门县| 乌拉特前旗| 阿城市| 颍上县| 新田县| 佛学| 雷山县| 额敏县| 潢川县| 营山县| 长海县| 任丘市| 兴国县| 柳林县| 太湖县| 涞水县| 特克斯县| 望奎县| 广宁县| 海安县| 大悟县| 静海县| 日照市|