- 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; } }
推薦閱讀
- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- PWA入門與實踐
- 潮流:UI設計必修課
- Dynamics 365 Application Development
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰
- AngularJS Web Application Development Blueprints
- Highcharts Cookbook
- Integrating Facebook iOS SDK with Your Application
- 單片機C語言程序設計實訓100例
- C++反匯編與逆向分析技術揭秘(第2版)
- Creating Data Stories with Tableau Public
- Maker基地嘉年華:玩轉樂動魔盒學Scratch
- Android Studio Cookbook
- 零基礎看圖學ScratchJr:少兒趣味編程(全彩大字版)