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

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;
    }
}
主站蜘蛛池模板: 合山市| 赣州市| 长沙市| 大英县| 扶风县| 喜德县| 贡嘎县| 平安县| 金山区| 奎屯市| 弥渡县| 广安市| 平谷区| 兴化市| 龙海市| 保康县| 镇坪县| 中阳县| 右玉县| 乌兰察布市| 渑池县| 封丘县| 锦屏县| 乳源| 华亭县| 龙游县| 高邮市| 苏尼特右旗| 铁力市| 万年县| 梁平县| 古丈县| 通州区| 阜宁县| 沈丘县| 都昌县| 甘孜| 昌乐县| 秀山| 昌江| 潼南县|