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
But when inspect in chrome .AspNet.ApplicationCookie is present if i edit and delete cookie application works fine.