書名: 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; } }
推薦閱讀
- The Complete Rust Programming Reference Guide
- PowerCLI Cookbook
- BeagleBone Media Center
- Learning Elixir
- 趣學Python算法100例
- 精通API架構:設計、運維與演進
- Mastering Python High Performance
- Monitoring Elasticsearch
- PostgreSQL Replication(Second Edition)
- Working with Odoo
- Apache Spark 2.x for Java Developers
- Learning Apache Cassandra
- Node.js 12實戰
- JavaScript程序設計:基礎·PHP·XML
- PHP+MySQL動態網站開發從入門到精通(視頻教學版)