我有一个问题...我有注册表单,当用户注册时,它会将他重定向到主页..我想在重定向他之前显示弹出消息,他已成功注册,然后将他重定向到主页。
控制器:
TempData["SuccessMessage"] = "A confirmation email will be sent to the address you've entered shortly";
return RedirectToAction("Index", "Home");
查看:
<script>
if (@TempData["SuccessMessage"] != null)
{
alert('@TempData["SuccessMessage"]');
}
</script>
答案 0 :(得分:0)
存储重定向网址就像这样
ViewBag.Redirect = "Your URL ";
并在下面提到java脚本
<script>
if (@TempData["SuccessMessage"] != null)
{
alert('@TempData["SuccessMessage"]');
window.setTimeout(function () {
location.href = @ViewBag.Redirect;
}, 5000);
}
</script>