Search code examples
c#asp.net-mvc.net-core-rc2

asp net core 1 RC2 AccountController injection


I created a asp.net core rc2 web application with user identity, however i'm confused how the account controller class is getting it's arguments, usermanager, signinmanager? Where are they being passed in from? I follow the call stack and I get external code, what external code is passing in these objects? Help me understand, how these 2 objects are being initialized.

enter image description here


Solution

  • In your Startup.cs you will see a call to this method

    services.AddIdentity<ApplicationUser, IdentityRole>()
    

    Afte reading the links on dependency injection suggested by @AndrésRobinet you can actually see where the services are being wired up.

    This extension method lives in `IdentityServiceCollectionExtensions - You can then go and look at the source code for this method call (.NET core is on github):

    line 67 of the AddIdentity method

    services.TryAddScoped<SignInManager<TUser>, SignInManager<TUser>>();
    

    what external code is passing in these objects?

    Right-click on External code and click Show External Code - now you can get an idea of what is happening under the hood. the code down to and including the Kestrel webserver is also browsable/downloadable on github

    enter image description here

    image truncated