我有一个名为_Layout.cshtml并放置在文件夹中的母版页Views/Shared/_Layout.cshtml。我创建了一个控制器:SharedController.cs将数据传递给_Layout.cshtml
但不进入控制器。如何将数据传递到每个加载母版页_Layout.cshtml?
这是控制器,例如:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace HAnnoZero.Controllers
{
public class SharedController : Controller
{
public ActionResult _Layout()
{
ViewBag.help = "ciao";
return View();
}
}
}
Run Code Online (Sandbox Code Playgroud)