I’m working on a website with the razor view engine and C# and have a question to the RenderPage() function.
I have a _PageStart with RenderBody() in it. This works fine and loads the requested page. But if I request e.g. http://www.page.com/products and the products.cshtml contains the function RenderPage() this function is not executed.
Is RenderPage() only working on the first level executed page (here _PageStart)? Is there a way to render pages in a rendered page?
Thank you
From what I understand from your question (I’m assuming you mean RenderPage when you said RenderBody), you have a page that calls RenderPage() to include another page, and the included page has another call to RenderPage() to yet include another page.
This should work. Just keep in mind the you paths are relative to the page where you are calling RenderPage(), and not the top level page inyour heirarchy. Also note that _ViewStart.cshtml is not evaluated for pages rendered using RenderPage() and so default parent layouts will not be used.
If you are still encountering any issues, post some source code so you can get a better answer.