I’ve been dissecting the Orchard CMS rendering and view engine in an effort to understand how it’s put together. I have discovered that neither RenderBody nor RenderSection are ever called. It is my understanding that the Razor view engine requires a call to one or the other.
What is it that gets around the requirement that RenderBody or RenderSection have to be called or an exception is thrown by Razor?
Is it the fact that there’s a custom view engine (ThemeAwareViewEngine)? If so, how does it handle parsing Razor syntax to generate the content?
Thank you.
It’s actually the other way around.
Razoritself doesn’t require thatRenderBodybe called it’s theRazorViewEnginethat has this requirement. There can definitely be another view engine that uses Razor that has a completely different way of working. Take a look at https://github.com/Antaris/RazorEngine or https://github.com/Buildstarted/RazorSharp I’ve also written a markdown view engine that uses razor for some simple layouts.From reading the source it looks as if they’ve created a few custom view engines. Their
RazorViewEnginereplaces the base class for razor generated files with their own customWebViewPagewhich has a methodDisplayof whichZoneis an alias for. This is what allows them to render child views in addition it seems as if there are several types of Zones within theLayoutAwareViewEnginesuch asDocumentZone,ContentZoneand so forth.So in the end they’ve done a lot of custom code.