//后端代码
public IActionResult Index()
{
ViewBag.User1 = "张三";
ViewData["User2"] = "李四";
TempData["User3"] = "王五";
HttpContext.Session.SetString("User4","赵六");
object User5 = "田七";
return View(User5);
}
//前端代码
@model String
<h2>User1=@ViewBag.User1</h2>
<h2>User2=@ViewData["User2"]</h2>
<h2>User3=@TempData["User3"]</h2>
<h2>User4=@Context.Session.GetString("User4")</h2>
<h2>User5=@Model</h2>