且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

设置HttpContext.Current.User从Thread.CurrentPrincipal中

更新时间:2023-12-03 20:00:34

首先:你需要设置在每次请求委托人

First of all: You need to set the principal on every request.

窗体身份验证使用它在每个请求校长自己的任务。这就是为什么你看到的的GenericPrincipal

Forms authentication uses it's own assignment of the principal on each request. That's why you are seeing the GenericPrincipal

我通常重新分配在OnPostAuthenticate我的自定义prinicpal当标准认证机制做

I usually reassign my custom prinicpal in OnPostAuthenticate when the standard authentication mechanism is done.