I got a controller which assign a value to the ViewBag and that ViewBag is used in the script,
this is my code, i have no idea whats wrong, i even tried using TempData but nothing happens everytime it shows that my ViewBag is null.
public ActionResult ChechUserNP(Login dd)
{
if (dd.userid == "admin" && dd.pwd == "admin")
{
return RedirectToAction("Index", "DataGridView");
}
else
{
@ViewBag.Message = "MyMessage";
return RedirectToAction("Index", "Login");
}
}
<script>
debugger;
if (@ViewBag.Message !== null) {
}
</script>