fp6sdq
Last Updated: February 25, 2016
·
5.157K
· analogj
57a90b685ef5eb6b17edf33fa91c4ea8

RazorEngine Html.Raw fix

While working on our cloud ebook manager QuietThyme, we looked into creating an emailing system that would allow myself and the other founders of QuietThyme to send emails immediately while also keeping a consistent and professional look.
To that end we began integrating RazorEngine, an open source templating engine based on Microsoft's Razor parsing engine that you can extend very easily to become an email templating system

One of the problems that we ran into during our integration was that any use of @Html.Raw("html string here") would result in an error "Unable to compile template. The name 'Html' does not exist in the current context".

The solution for this problem was found in a github issue and I thought it could be helpful to another developer attempting to use RazorEngine with @Html.Raw() to give it a bit more publicity.

@(new RawString("<strong>Bold!</strong>"))

Or, just use:

@Raw("<strong>Bold!</strong>")
Say Thanks
Respond

2 Responses
Add your response

10709
7ae85605232e945cf097764f2805f483

Only problem with this is I don't get any intellisense for @Raw. I don't know if that's just a configuration issue on my part - but if so, what did I do wrong!? ;)

over 1 year ago ·
26505
None

Thank you, this was killing me.

over 1 year ago ·