如何将razor生成的html转换为字符串?

Ama*_*nes 5 c# umbraco umbraco8

我使用 umbraco 创建了一个工作流程,我想做的是:创建一个工作流程,获取由 razor 模板 ( umbraco.forms) 创建的 html。

这是模板的位置umbraco.forms

Views\Partials\Forms\Emails 此模板是我想要在调用此工作流程时通过电子邮件发送的模板。

public class SendMail : WorkflowType
{  
    //Here I get the path where the razor template is
    [Umbraco.Forms.Core.Attributes.Setting("Path to template",
     Description = "Path to template",
     View = "TextField")]
     public string Template{ get; set; }
   public SendMail()
   {

    this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0204");
    this.Name = "Send Mail";
    this.Description = "Send Mail";
    this.Icon = "icon-plugin";
    this.Group = "Services";
   }
    //When workflow get called this method is executed 
    public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
   {

      //here I'm trying to get the template converted to string however isn't work
     //  string template = html.Raw(Template).ToString();
   }

}
Run Code Online (Sandbox Code Playgroud)

我尝试过string template = html.Raw(Template);,但无法访问html.Raw("");

我已经尝试过这个解决方案,但似乎record.ParseWithRazorView(filePath);不存在

有一个工作流程可以完成一些接近的工作,但似乎我无法重写或访问此代码

在此输入图像描述

如果您不完全理解我假装的内容,请发表评论,我将更新问题的所有详细信息

Ama*_*nes 0

我创建了一个视图和一个umbraco 控制器

namespace name.Core.Controllers
{
    public class TemplateController : Umbraco.Web.Mvc.SurfaceController
    {
        public ActionResult Template()
        {

            return View();
        }
   }
}
Run Code Online (Sandbox Code Playgroud)

我将 URL 传递到“pathtoTemplate”中

 public static class TemplateHTML
    {
        public static string GetTemplate(string pathtoTemplate)
        {
            using (WebClient client = new WebClient())
            {
                var encodingbody = client.DownloadData(CaminhoTemplate);
                return Encoding.UTF8.GetString(encodingbody);
            }
        }
    }

var body = TemplateHTML.GetTemplate("http://example.com/umbraco/surface/Template/Template")
Run Code Online (Sandbox Code Playgroud)