简体   繁体   中英

asp.net Identity tables not get created

I'm using the web api 2.2 template with OWIN and Identity framework. I've purposefully set my DeafultConnection to a bad IP address yet I get no errors when stepping through and getting a bearer token and creating claims.

I can kill the w3wp.exe, start it up again and my token is still valid. So where is it getting persisted?

I am manually validating a test user in my GrantResourceOwnerCredentials() method

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 tokens are not persisted at all, in the default Owin OAuth2 implementation they are stateless by design. Each token contains the claims issued for the user encrypted by the server so that only it can decrypt and validate it.

If you validate your user without hitting your database (I assume this is what you mean when you say manually inside your GrantResourceOwnerCredential method) then of course you DbContext never get instantiated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM