1

I need generate email by template base's on razor engine.

Business logic is class library Project. I added System.Web.Razor and RazorEngine.

And created simple cshtml file, but this file don't work like simple razor cshtml. Do not have @model BlablaViewModel but work @foreach, @for, @if

How to user razor power in class library project ?

UPDATE it is not duplicated. I need use razor with viewModel but their solutions do not help me.

Mediator
  • 14,387
  • 34
  • 108
  • 180

2 Answers2

0

ActionMailer might be able to do this for you. It's capable of using Razor templates to generate emails but I don't know how easy it is to get it to work inside a class library project.

https://bitbucket.org/swaj/actionmailer.net/wiki/Home

Spencer Ruport
  • 34,575
  • 11
  • 83
  • 145
0

Another solution is to check out ServiceStack.Razor. I have successfully implemented razor websites, in DLLs, using pages as embedded resources. This allowed me to have a "Common" DLL that had layouts, CSS, javascript, etc, and other DLLs that provided the actual implementation. Said "common" dll is easily deployable and shareable amongst multiple web applications.

Moo-Juice
  • 37,292
  • 10
  • 72
  • 122