Dheeraj Sharma

Dheeraj Sharma

  • NA
  • 98
  • 29.1k

how to redirect page in string method(MVC)

Jan 3 2018 12:21 AM
i want to redirect my page to Login Page when user clicks on logout,
how can i redirect, below is my code
 
public string LogOut(Login log)
{
   using (simpleEntities dbContext = new simpleEntities())
   {
      int ID = Convert.ToInt32(log.ID);   
      Login s_data = dbContext.Logins.Where(x => x.ID == ID).FirstOrDefault();
      log.LogoutTime = DateTime.Now;
      log.Status = 0;
      dbContext.SaveChanges();
      FormsAuthentication.SignOut();
      Session.Abandon();
      Session.Clear();
      Response.Cookies.Clear();
      Session.RemoveAll();
   }
   return RedirectToAction("Login", "Login");
}
 
 
i tried using  return RedirectToAction("Login", "Login");  but it shows me error....
can anyone help me to solve this out.. 
 

Answers (3)