[RESOLVED] pass html into razor.
Hello
I am new to the whole MVC/Razor style of coding.
I am trying to pass a string to a cshtml file. The string is html. how can I do this. Here is the code -
Code:
@{
ViewBag.Title = Model.Title;
}
@{
@Model.CVBuilderInformation
}
And
Code:
model.CVBuilderInformation =
"<p>The Personal Professional Profile can be used to record information about your career, your education and your professional development and achievements in both work and personal life.</p> <a href="http://www.soemthing.co.uk"
target="_blank">www.something.co.uk</a>
I did it this way as the above text is not always shown. But when I run it puts the text out as a string, not html. Can you do that?
Thanks
Kev.
Re: pass html into razor.
C# Razor Syntax Quick Reference
Don't forget that generating raw HTML from the Controller could leave you open to potential XSS attacks.
Re: pass html into razor.
Thanks for that. Worked like a dream.
Kev.