RazorEngine and parsing physical view files always causes exception

前端 未结 3 425
悲&欢浪女
悲&欢浪女 2021-02-02 18:10

I have the following RazorEngine call:

public class RazorEngineRender
{
    public static string RenderPartialViewToString(string templatePath, string viewName,          


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 18:34

    Here are a few hints you might try:

    1. Make your razor view strongly typed to a model:

      @model Foo
      
      
    2. When rendering it pass a Foo model:

      _emailService.Render(
          TemplatePath, 
          "Email.cshtml", 
          new Foo { ActivationLink = activationLink }
      )
      
    3. If you are trying to send emails from your Views make sure you checkout Postal before reinventing something.

提交回复
热议问题