0

I am using mvc application using claim based authentication application works fine on both local and web sever

Code for Login action as below

 public ActionResult Login(LoginViewModel model, string returnUrl)
    {
        if (!ModelState.IsValid)
        {
            return View(model);
        }

        var repository = new AccountRepository();
        var user = repository.Get().Where(x => x.Username == model.Username).FirstOrDefault();
        if (user != null)
        {
            var password = EncryptionKeys.Encrypt(model.Password);
            if (user.Password.Equals(password))
            {
                var userRole = (EnumUserRole)new RoleRepository().Get(user.RoleId).Code;

                var claims = new List<Claim>();
                claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Username));
                claims.Add(new Claim(ClaimTypes.Name, user.FirstName));
                claims.Add(new Claim(ClaimTypes.Email, user.Email));
                claims.Add(new Claim(ClaimTypes.Role, userRole.ToString("g")));
                claims.Add(new Claim(ClaimTypes.Sid, user.Id.ToString()));

                var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                var ctx = Request.GetOwinContext();
                var authenticationManager = ctx.Authentication;
                authenticationManager.SignIn(id);


                return RedirectToPortal(userRole, user);
            }
        }

}

The issue is randomly after some passage of time error occurred. The error is system cannot find the file specified but stack trace tells that network connection is not established see in Image 1

Image 1

But when inspect in chrome .AspNet.ApplicationCookie is present if i edit and delete cookie application works fine.

Image 2

Enigmativity
  • 113,464
  • 11
  • 89
  • 172
waqar
  • 23
  • 1
  • 5
  • This doesn't appear to be about programming. It appears to be a debugging exercise. StackOverflow is a programming-related Q&A site. You should read [ask] and provide us with a [mcve] if this is indeed about programming. – Enigmativity Jul 24 '17 at 07:31
  • Are you leaving connections open on the SQL Server and running out of available connections? – Mauro Jul 24 '17 at 07:43
  • I am using linq to entity framework and available connections presents. when i delete .AspNet.ApplicationCookie cookie its works fine. – waqar Jul 24 '17 at 07:48
  • Thanks https://stackoverflow.com/users/2722645/neeraj-mehta on https://stackoverflow.com/questions/22737373/how-to-deploy-asp-net-mvc-4-application-using-localdb-to-local-iis-on-windows-7 Issue is resolved – waqar Jul 27 '17 at 15:01

0 Answers0