ASP.Net Identity - Multiple Authentication Methods

2019-08-13 23:57发布

问题:

Is it possible to configure the new ASP.Net Identity system to support multiple authentication methods?

I have a requirement to support both Windows authentication (Intranet) and application level users (ideally using the Entity Framework option). This seems to be almost impossible in the old ASP.Net Membership world but has anything changed with the new OWIN based implementation?

I need a scenario where Windows Auth is attempted first and then, if it fails, the site falls back to application level authentication.

As a secondary question, how do you go about adding the Entity Framework tables to support this to an existing database in an app that is using Database First?

回答1:

I need a scenario where Windows Auth is attempted first and then, if it fails, the site falls back to application level authentication.

Add a project for each type of authentication.

As a secondary question, how do you go about adding the Entity Framework tables to support this to an existing database in an app that is using Database First?

Entity Framework will handle this for you when you upload your site to the server. Just use multiple DbContext. They don't have to be part of the same table as long as you reference them correctly.



回答2:

To answer your second question. Go to the connection string. Find the location of the DB context and import it to your DB.