using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace WebAppMVC.Controllers { public class FirstController : Controller { //1 需要写上路由名字的吧 public IActionResult Index() { // MVC开发传值 { // 业务逻辑 计算 // 结果要展示给view // base.ViewBag.User1 = "张三"; base.ViewData["User2"] = "李四"; base.TempData["User3"] = "王五"; //base.HttpContext.Session["User4"] = "赵六"; object model = "Richard"; } return View(); } } }
代码写了,但是没有正确显示出来值,什么原因?
路径用的: /first/index
效果