- ASP.NET Web API Security Essentials
- Rajesh Gunasundaram
- 64字
- 2021-07-30 10:15:54
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; } }
推薦閱讀
- Practical Data Analysis Cookbook
- The Supervised Learning Workshop
- DBA攻堅指南:左手Oracle,右手MySQL
- Visual FoxPro程序設計教程
- 小創客玩轉圖形化編程
- 高效微控制器C語言編程
- Android 9 Development Cookbook(Third Edition)
- Hadoop+Spark大數據分析實戰
- RISC-V體系結構編程與實踐(第2版)
- Learning FuelPHP for Effective PHP Development
- 數據結構與算法分析(C++語言版)
- Learning Material Design
- 后臺開發:核心技術與應用實踐
- Mastering OpenStack
- Raspberry Pi Robotic Projects