I have an action I call from an anchor thusly, Site/Controller/Action/ID where ID is an int.
Later on I need to redirect to th
If one want to Show error message for [httppost] then he/she can try by passing an ID using
return RedirectToAction("LogIn", "Security", new { @errorId = 1 });
for Details like this
public ActionResult LogIn(int? errorId)
{
if (errorId > 0)
{
ViewBag.Error = "UserName Or Password Invalid !";
}
return View();
}
[Httppost]
public ActionResult LogIn(FormCollection form)
{
string user= form["UserId"];
string password = form["Password"];
if (user == "admin" && password == "123")
{
return RedirectToAction("Index", "Admin");
}
else
{
return RedirectToAction("LogIn", "Security", new { @errorId = 1 });
}
}
Hope it works fine.