Jaseem Abbas Jaseem Abbas - 1 year ago 228
ASP.NET (C#) Question

Razor tag inside Html.Raw(...)

Is it possible to render Razor in

? I have a dynamic page being generated that uses the
method to render the page that is created in the controller. My raw html has razor tags in it. That is, I am trying to generate a link by




I need the value of
to be rendered when
is called within the cshtml.

Answer Source

You may have some architectural issues that lead you to have some razor code on your Model property.

Anyway, you can do it by using some external libs such RazorTemplates.

Here is a sample :

var template = Template.Compile(Model.myRawHtmlContainingRazorTags);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download