📜  如何设置当前用户 httpcontext.current.user asp.net -mvc - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:39.089000             🧑  作者: Mango

代码示例1
String[] newRoles = { "Administrator", "Customer" };
GenericIdentity newIdentity = new GenericIdentity(model.AccountName);
GenericPrincipal newPrincipal = new GenericPrincipal(newIdentity, newRoles);                       
System.Web.HttpContext.Current.User = newPrincipal;