在controller內加上ShowData["message"]="mvc 測試";
public ActionResult Login()
{
ShowData["message"]="mvc 測試";
return View();
}
view內加上處理判斷
@{
if (ShowData["message"] != null)
{
<script type="text/javascript">
var message = @Html.Raw(Json.Encode(ShowData["message"]));
alert(message);
</script>
}
}