【发布时间】:2015-08-21 14:34:59
【问题描述】:
带有 asp.net 身份的网络 api 这是我的代码:
public class ApplicationUser : IdentityUser
{
public string FullNamme { get; set; }
public string ProfileType { get; set; }
public ClaimsIdentity GenerateUserIdentity(ApplicationUserManager manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = manager.CreateIdentity(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
public Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
{
return Task.FromResult(GenerateUserIdentity(manager));
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
如果是客户或专业人士,我想根据public string ProfileType { get; set; } 管理授权...
类似的东西[Authorize(TypeProfile="xxx")] ...
如果不可能,我如何向我的代码添加简单角色,以及如何定义默认登录页面以在用户未登录时重定向。
希望你能帮帮我..
【问题讨论】:
标签: c# asp.net asp.net-web-api webforms