c# - MVC5 WebSecurity, use secondary database temporarily -


i have solution 2 mvc projects. first management system, second portal contractors. want manage contractor login of portal via main application.

the membership database both projects identical in schema (the default). thought hijack main system's register action, swap out connection string, register contractor user in its' own database, swap connection string main one.

i'm guessing won't work, namely based on fact websecurity.initializedatabaseconnection() can called once.

thus question: if want call websecurity.createuserandaccount() method point different database initialized for, how so?

i looked @ built-in initializesimplemembership filter clues, not seeing path i'm looking for.

is feasible approach?

alternatively, if can password hashed per same way it's done default, looks can enter required data db manually.

it appears can manually work out. according msdn docs websecurity.createuserandaccount():

this method creates new entry in user profile table , corresponding entry in membership table. id of membership entry based on id of user profile entry. (the ids of entries in 2 tables match.)

(https://msdn.microsoft.com/en-us/library/webmatrix.webdata.websecurity.createuserandaccount(v=vs.111).aspx)

inspecting database schema shows need 2 tables this, , fields straigtforward.

to hash password according same way simplemembershipprovider does, can use system.web.helpers.crypo.hashpassword() method.

this simplifies basic account creation considerably don't have piggyback off accountcontroller , can write these directly db , call (for purposes, anyway, not requiring verification tokens , having seperately handled email notifications). on portal side, built-in simplemembershipprovider should able handle usual.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -