Conditionally Include Partial View in ASP.NET Core
See the original posting on DZone Python
I have an ASP.NET Core web application where I need to include a partial view only if it exists. The application uses areas and some areas may have their specific side menu. This blog post shows two ways to conditionally include a partial view in an ASP.NET Core layout page.
My goal is to do it the easiest way possible by using out-of-the-box things and making sure I don’t create an ugly looking mess. I wanted to avoid all kinds of additional classes to wrap dirty secrets away from controllers and views.