GenerateUserIdentity 在此方法中,我需要根据域名获取当前域名,我需要添加声明值。 Asp.net 4.5 框架

问题描述 投票:0回答:0

public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
在这种方法中,我需要在身份声明中添加域名。

从 2 个地方调用的方法 1 是 startup.auth,如下所示。

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.  
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity\<ApplicationUserManager, ApplicationUser\>(
validateInterval: TimeSpan.FromMinutes(2),
regenerateIdentity: (manager, user) =\> user.GenerateUserIdentityAsync(manager))
}
});

2nd 来自 identityConfig

public override Task\<ClaimsIdentity\> CreateUserIdentityAsync(ApplicationUser user)
{
return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager,this.subdomain);
}

请告诉我该怎么做。 我使用了内置的 Asp.net 身份结构。

我想要在声明身份中使用域名。

claims-based-identity
© www.soinside.com 2019 - 2024. All rights reserved.