- 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; } }
推薦閱讀
- OpenShift開發(fā)指南(原書第2版)
- 數(shù)據(jù)庫原理及應用(Access版)第3版
- Rust編程:入門、實戰(zhàn)與進階
- 網(wǎng)頁設計與制作教程(HTML+CSS+JavaScript)(第2版)
- Python高級機器學習
- JAVA程序設計實驗教程
- RabbitMQ Essentials
- App Inventor創(chuàng)意趣味編程進階
- Spring+Spring MVC+MyBatis從零開始學
- 移動增值應用開發(fā)技術導論
- 運維前線:一線運維專家的運維方法、技巧與實踐
- Node.js 12實戰(zhàn)
- Nagios Core Administration Cookbook(Second Edition)
- 零代碼實戰(zhàn):企業(yè)級應用搭建與案例詳解
- 軟件體系結構