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

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;
    }
}
主站蜘蛛池模板: 合川市| 浑源县| 蛟河市| 修武县| 湘潭县| 合江县| 大庆市| 香格里拉县| 武汉市| 靖州| 简阳市| 怀集县| 阳山县| 竹山县| 会理县| 浦江县| 隆德县| 环江| 化州市| 咸宁市| 历史| 洛浦县| 南雄市| 舞阳县| 屏南县| 垣曲县| 昌黎县| 喀喇沁旗| 富阳市| 丰台区| 小金县| 三明市| 湘阴县| 湟中县| 合山市| 临湘市| 巴林左旗| 金阳县| 龙岩市| 富民县| 石渠县|