I'm encountering an issue with the following code within the body tag of a view in MVC. The alert message displays the first time the page loads, but it doesn't execute when the control is coming through a redirect.
Despite setting breakpoints and confirming that the code is executing, the alert line itself does not run.
@{
<script type="text/javascript>
@if (TempData["notice"] != null)
{
@:alert(TempData["notice"]);
}
else
{
@:alert("No notice");
}
</script>
}