0

How can I compile/render html helpers that are used inside my html template that is stored in my database?

The current view shows this:

enter image description here

But the @ values should be compiled already.

The view that renders this output contains this code, where @Model.Content contains the html markup.

@{
    ViewBag.Title = Model.Title;
}

@section meta{
    <meta name="description" content="@Model.Description" />
    <meta name="keywords" content="@Model.Keywords" />
}


@Html.Raw(Model.Content)
Rob Angelier
  • 2,335
  • 16
  • 29
  • First, remove `Html.Raw`. – Andrei V Feb 03 '15 at 08:37
  • i don't think you have not stored compile partial page. It still have razor syntax in database. Please check database data. – Ankush Jain Feb 03 '15 at 08:44
  • @AndreiV and second? I just stored the markup and I want to compile it before someone loads the page and then return it. – Rob Angelier Feb 03 '15 at 08:53
  • Second: ???, third: profit! :) Sorry, I can't help any further. I have no idea. I've done a quick search but don't really have the time to investigate more. I have no doubt that this is possible, though. I just know that if your use `Html.Raw`, it'll be surely interpreted as text. – Andrei V Feb 03 '15 at 09:05
  • @AndreiV ok, no problem! I know that the Raw method is incorrect for this situation. I'm wondering if it's possible to compile the view manually and then return it. I couldn't find anything either. Thanks though. – Rob Angelier Feb 03 '15 at 09:19
  • http://www.umbraworks.net/bl0g/rebuildall/2009/11/17/ASP_NET_MVC_and_virtual_views and http://stackoverflow.com/questions/4218454/asp-net-mvc-load-razor-view-from-database – timothyclifford Feb 03 '15 at 13:57

0 Answers0