How do I pass data from my partial view to my main layout in ASP Core?
I have this code in my partial view:
Now I want to pass this data to my main layout.
What I want to do here is to set
ViewData["LessonTitle"]
in my partial layout and get that data in my _Layout.cshtml
but I get the error NullReferenceException: Object reference not set to an instance.
specifically on the <h1>@ViewData["LessonTitle"]</h1>
line, if I remove that line I don't get any error at all so I believe I can't pass data from partial view to layout via ViewData....? If I can't, how do I pass data from my partial to my main layout?0 Replies