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..
Laxmidhar SahooPosted Jan 3, 2018, 4:19 AM
Dharmraj ThakurPosted Jan 3, 2018, 2:04 AM
1) If you change string to ViewResult then it will redirect directly.
2) Otherwise you have to call this LogOut() by ajax request and return some data to ajax success callback. then redirect page in javascript code. like below...
Page Not Found! Error 404
";Mangesh GPosted Jan 3, 2018, 12:34 AM