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

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;
    }
}
主站蜘蛛池模板: 宣威市| 平果县| 天峨县| 兴宁市| 玉树县| 德昌县| 湛江市| 台南县| 军事| 新源县| 千阳县| 黄石市| 土默特右旗| 藁城市| 毕节市| 宜宾县| 河北省| 鹿邑县| 清苑县| 兴文县| 沂水县| 韶关市| 日土县| 仪征市| 芦山县| 永胜县| 舒兰市| 新龙县| 班玛县| 伊吾县| 临猗县| 天台县| 调兵山市| 泰宁县| 安庆市| 开远市| 南华县| 静宁县| 张北县| 鸡西市| 三明市|