In ASP.NET MVC how can I pass a String variable to the _Layout.cshtml view; ViewBag and ViewData don’t seem to work, is there another/prefered way?
Best Wishes, Yends
In ASP.NET MVC how can I pass a String variable to the _Layout.cshtml view; ViewBag and ViewData don’t seem to work, is there another/prefered way?
Best Wishes, Yends
ViewBag/ViewData work fine. For example:
public ActionResult Index()
{
ViewBag.Message = "Hello World";
return View();
}
and inside _Layout.cshtml:
<div>@ViewBag.Message</div>