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

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;
    }
}
主站蜘蛛池模板: 蛟河市| 仁布县| 文成县| 阿拉尔市| 介休市| 涿州市| 工布江达县| 岳阳市| 长治县| 特克斯县| 波密县| 长子县| 黄梅县| 法库县| 马公市| 弋阳县| 尼木县| 绥棱县| 梓潼县| 南城县| 浦县| 双江| 买车| 龙江县| 大关县| 满洲里市| 县级市| 太仓市| 洛阳市| 全州县| 湖北省| 马尔康县| 陇川县| 盐边县| 渭源县| 岚皋县| 雷山县| 洮南市| 准格尔旗| 洪洞县| 仲巴县|