c# - Asp.Net Identity sample - Where injected for account controller? -
when create asp.net identity individual account, notice in account controller construct method, there 2 parameters.
public accountcontroller(applicationusermanager usermanager, applicationsigninmanager signinmanager ) { usermanager = usermanager; signinmanager = signinmanager; }
i want know when have been injected? because havent seen di tools.
thanks
by default, there no dependency injection tools in sample application created visual studio asp.net web application using .net framework , individual accounts.
my guess constructor created in order allow plug in di framework. key in properties declared in accountcontroller
getting these dependencies. example, see signinmanager
property:
public applicationsigninmanager signinmanager { { return _signinmanager ?? httpcontext.getowincontext().get<applicationsigninmanager>(); } private set { _signinmanager = value; } }
if create instance of accountcontroller
through empty constructor, code see _signinmanager
has not been set , instead retrieve current owin context. however, if using di constructor, _signinmanager
have value , used instead.
note how access applicationsigninmanager
class made through signinmanager
property on accountcontroller
. e.g.:
var result = await signinmanager.passwordsigninasync( model.email, model.password, model.rememberme, shouldlockout: false);
here, signinmanager
property i've included above.
for more on how owin context resolution has been set up, see following code in startup.auth.cs
:
app.createperowincontext<applicationusermanager>(applicationusermanager.create);
this enables httpcontext.getowincontext().get<applicationsigninmanager>()
thing.
Comments
Post a Comment