asp.net mvc - How to resolve an user repository using Windsor IoC at the start of the application? -


I get an error message "Object reference is not set to an object instance." When I try to use a UserRepos repository, the question is how can I fix the user repository at the beginning of the application (ASP.NET MVC) What's wrong here?

  Public Class My Unification: HTTP Application {Public IUserRepository UserRepos; Public IWindsorContainer Container; Protected Zero application_Start () {Container = New Windsor Container (); // Application Services Container & Lt; iUserRepository & gt; (); Applicable; & lt; UserRepository & gt; ()); UserRepos = Container Resolve & lt; IUserRepository & gt; (); } Private Zero On Authentication (Object Sender, Event Argus E) {If (user! = Null) (if user.notification.asauthenticated) {// here error "object reference is not set for an instance of an object . " Var user = user repose.get userbainname (context user.indenti .name); Var Principal = new MyPrincipal (user); Thread Custom Principal = Context. User = principal; Return; }}}}  

Thanks for helping me!

The reason for this exception is the misunderstanding of the HTTP application life cycle. These articles consider it quite well:

  • In your case, this will be the correct container usage:


    Comments

    Popular posts from this blog

    c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

    Calling GetGUIThreadInfo from Outlook VBA -

    Obfuscating Python code? -