Asp.Net:在httpcontext.current.items中存储Principal

Pic*_*els 0 .net asp.net asp.net-mvc

我想知道在httpcontext.current.items而不是httpcontext.current.user中存储自定义Principal是否有任何缺点.我知道你需要为每个请求设置它,但我也必须使用httpcontext.current.user.

提前致谢,

Pickels

rou*_*uen 5

HttpContext.Current.User是"授权基础架构"期望Principal所在的位置,并将在此处查找.因此,当他在那里时,许多与授权相关的功能(例如基于IsInRole)将自动工作,当您将他存储在其他地方时,您将不得不"破解"他们的工作.

罗马