Tag: iidentity

使用自定义成员资格和角色提供程序在MVC中实现IPrincipal和IIdentity

我坚持使用自定义iprincpal和iidentity对象的实现。 我现在花了一天时间来搜索如何实现这些权利并用更多信息扩展它。 我想用自定义变量(如全名或其他)扩展Information @Context.User.Identity.Name 。 编辑 :现在我得到以下代码,但如果我尝试阅读@((CustomPrincipal)Context.User.Identity).Nachname我收到一个错误, System.Web.Security.FormsIdentity无法转换为CustomPrincipal 。 有任何想法吗? public class CustomPrincipal : GenericPrincipal { public CustomPrincipal(IIdentity identity, String[] roles) : base(identity, roles){ } public String Vorname { get; set; } public String Nachname { get; set; } } AccountModel: public class FormsAuthenticationService : IFormsAuthenticationService { public void SignIn(string userName, bool createPersistentCookie) { if […]

设置线程标识

在C#中,如何设置线程的标识? 例如,如果我已经启动了Thread MyThread,我可以更改MyThread的身份吗? 或者这不可能吗?