- 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; } }
推薦閱讀
- Kali Linux Web Penetration Testing Cookbook
- 編程的修煉
- 零基礎(chǔ)學(xué)C++程序設(shè)計(jì)
- Java Web基礎(chǔ)與實(shí)例教程(第2版·微課版)
- Full-Stack React Projects
- Mastering Apache Spark 2.x(Second Edition)
- C語(yǔ)言程序設(shè)計(jì)學(xué)習(xí)指導(dǎo)與習(xí)題解答
- 網(wǎng)站構(gòu)建技術(shù)
- Unity 2018 Shaders and Effects Cookbook
- Python項(xiàng)目實(shí)戰(zhàn)從入門(mén)到精通
- Instant Debian:Build a Web Server
- OpenCV Android Programming By Example
- 青少年學(xué)Python(第2冊(cè))
- Building Business Websites with Squarespace 7(Second Edition)
- JavaScript編程精解(原書(shū)第3版)