Error logging into applications

2

Well, the scenario is as follows:

I have 2 applications ASP.NET MVC in a same project, which is using a Dominio in common. I'll call MVC1 and MVC2 to get better at the sample.

I've installed Identity , EntityFramework on dominio , and almost everything so far it seems to work normally.

No MVC1 logo normally, and if you access the system MVC2 shows me that I am logged in. I can log off among other features. Which makes me think that everything is OK.

Now let's go ...

The only problem I had was logging into the MVC2 project. I get the error:

  

Server Error in Application '/'. Object reference not set   for an instance of an object. Description: An exception occurred without   during the execution of the current Web request.   stack trace for more information about the error and where   was originated in the code.

     

Exception Details: System.NullReferenceException:   object not set to an instance of an object.

     

Source Error:

     

Line 74: // This does not count login failures towards   account lockout Line 75: // To enable password failures   to trigger account lockout, change to shouldLockout: true

     

Line 76: var result = await SignInManager.PasswordSignInAsync (model.Email,   model.Password, model.RememberMe, shouldLockout: false);

     

Line 77:
  switch (result) Line 78:

Code of controller :

 [HttpPost]
 [AllowAnonymous]
 [ValidateAntiForgeryToken]
 public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
   {
        if (!ModelState.IsValid)
        {
            return View(model);
        }
        var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
        switch (result)
        {
            case SignInStatus.Success:
                return RedirectToLocal(returnUrl);
            case SignInStatus.LockedOut:
                return View("Lockout");
            case SignInStatus.RequiresVerification:
                return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return View(model);
        }
    }

However, Debugging , I put a BreakPoint on line 76 of controller which is the one that generates the error, the required fields for login are filled in

And I have seen that logging through MVC1 (which soon normally without the error) does not enter this controller method. Since MVC2 enters and returns the error quoted above.

How do I solve this problem?

    
asked by anonymous 15.12.2016 / 05:06

1 answer

2

Probably missing the dependency injection. Check your Startup.Auth.cs file if SignInManager is being instantiated correctly:

app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
    
15.12.2016 / 20:30