示例控制器:

        public ActionResult Index()
        {
            ViewBag.js = "<script type='text/javascript'>alert('abc');</script>";
            return View();
        }

页面:

<html>
<head>
    <title>Demo</title>
</head>
<body>
    <div>
        @Html.Raw(ViewBag.js)
    </div>
</body>
</html>

就可以了