如何使用剃刀视图引擎在一个控制台应用程序? [英] How to use Razor View Engine in a console application?
本文介绍了如何使用剃刀视图引擎在一个控制台应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的控制台应用程序需要从发送HTML电子邮件。我想编写HTML格式的电子邮件在剃刀视图,且具有发动机产生的电子邮件正文内容。
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?
推荐答案
有一个开源项目,它允许使用剃须刀作为一般的模板引擎:这就是所谓的RazorEngine (在code在 GitHub上)
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)
该项目的页面的示例:
string template = "Hello @Model.Name! Welcome to Razor!";
string result = Razor.Parse(template, new { Name = "World" });
这篇关于如何使用剃刀视图引擎在一个控制台应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文