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,951
  • 35
  • 113
  • 191

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,865
  • 12
  • 85
  • 147
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
  • 38,257
  • 10
  • 78
  • 128