How do I use Razor View Engine in a console application?


My console app needs to send html emails from. I'd like to write the emails in html format in a Razor view and have the engine generate the email body content.

This means no controllers or requests. How could I go about this?

There is an open source project which allows to use Razor as a general templating engine: it's called RazorEngine (the code in on GitHub)

A sample for the project's page:

string template = "Hello @Model.Name! Welcome to Razor!";
string result = Razor.Parse(template, new { Name = "World" });