I am storing user-editable HTML layouts inside a database, but I would like to know if there’s a way to render a partial view in the middle of some of that content.
For example:
<div>
This is the header
@Html.Action("WebsiteTemplate", "Page")
</div>
I’ve thought that I could split the top & lower content into 2 separate columns, but is there a better way to accomplish this?
What you need is to parse with Razor content which you retrieved from database. You may use RazorEngine project for that purpose. It has some limitations (like,
@Raw()instead of@Html.Raw()), but cover many scenarios.