Suppose I have many views, each displaying very similar content. Each view uses the same _Layout as defined in _ViewStart.
My _Layout might look like this:
<html>
<!-- some html -->
@ViewBag.SomeViewBagFun
<!-- more html -->
@RenderBody
<!-- more html -->
@SpecialFunction()
</html>
Helper SpecialFunction()
@<a href="/">Linky</a>
@<!-- complex HTML -->
End Helper
Suppose 90% of my pages use the default SpecialFunction()
as defined in the layout, but occasionally some views want a different SpecialFunction()
.
One way to resolve this is to use ViewBag
and send each view content that way, but SpecialFunction()
contains complex HTML and I want to use razor views.
How do I achieve this?