(1)在前端获取Cookie的方法:
Step1:在后台获取Cookie值并存入ViewBag中
HttpCookie cookie = Request.Cookies["username"];
ViewBag.username = cookie.Value.ToString();
Step2:在前端输出ViewBag
在前端直接使用@ViewBag.username即可
(2)在前端判断ViewBag是否为空
(3)在js中输出HTML
使用document.write('<input />');//直接写html标签即可
单引号或者双引号都可以,也注意一下HTML标签中的引号