asp.net 未创建身份表
asp.net Identity tables not get created
我正在使用带有 OWIN 和身份框架的 Web api 2.2 模板。我故意将我的 DeafultConnection 设置为错误的 IP 地址,但在单步执行并获取不记名令牌和创建声明时我没有收到任何错误。
我可以杀死 w3wp.exe,重新启动它,我的令牌仍然有效。那么它在哪里得到持久化?
我在 GrantResourceOwnerCredentials() 方法
中手动验证测试用户
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
I can kill the w3wp.exe, start it up again and my token is still valid. So where is it getting persisted?
OAuth 令牌根本不会保留,在默认的 Owin OAuth2 实现中,它们在设计上是无状态的。每个令牌都包含为服务器加密的用户发出的声明,因此只有它可以解密和验证它。
如果您在不访问数据库的情况下验证您的用户(我假设这就是您在 GrantResourceOwnerCredential
方法中说 手动 时的意思)那么您当然 DbContext
永远不会实例化。
我正在使用带有 OWIN 和身份框架的 Web api 2.2 模板。我故意将我的 DeafultConnection 设置为错误的 IP 地址,但在单步执行并获取不记名令牌和创建声明时我没有收到任何错误。
我可以杀死 w3wp.exe,重新启动它,我的令牌仍然有效。那么它在哪里得到持久化?
我在 GrantResourceOwnerCredentials() 方法
中手动验证测试用户public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext() : base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
I can kill the w3wp.exe, start it up again and my token is still valid. So where is it getting persisted?
OAuth 令牌根本不会保留,在默认的 Owin OAuth2 实现中,它们在设计上是无状态的。每个令牌都包含为服务器加密的用户发出的声明,因此只有它可以解密和验证它。
如果您在不访问数据库的情况下验证您的用户(我假设这就是您在 GrantResourceOwnerCredential
方法中说 手动 时的意思)那么您当然 DbContext
永远不会实例化。