I was wondering if there\'s a way to specify a model for the _layout.cshtml file, i\'ve seen lots of posts with the basic same question with people replying with \"alternati
In BaseController you can declare any model as property.
public class BaseController : Controller
{
public BaseController ()
{
MyTag = new TagModel (); // or get db, take any value from there
}
public TagModel MyTag { get; set; }
}
In action:
ViewBag.MyTag = MyTag ;
And in _Layout.cshtml, you can use
@{
var myTag = (TagModel)ViewBag.MyTag;
}