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

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;
    }
}
主站蜘蛛池模板: 东至县| 冀州市| 临湘市| 康乐县| 无极县| 衡水市| 长阳| 黄陵县| 陆良县| 三台县| 上犹县| 滨海县| 兴安县| 武陟县| 和顺县| 玛多县| 横山县| 诸暨市| 静安区| 南溪县| 高阳县| 安吉县| 舟曲县| 芒康县| 华池县| 和田市| 开封县| 彩票| 察雅县| 常山县| 昂仁县| 丰原市| 万山特区| 江源县| 金秀| 福鼎市| 穆棱市| 平果县| 朝阳区| 和顺县| 白银市|