I'm trying to integrate Postal with precompiled views generated by RazorGenerator, but I am not having any success. I am using RazorGenerator and Postal in a shared DLL to isolate all email logic in my codebase. I have two ASP.NET apps that use this shared DLL to send emails. RazorGenerator auto generates the following code and configures it to run when the application is started:
public static class RazorGeneratorMvcStart
{
public static void Start()
{
var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly)
{
UsePhysicalViewsIfNewer = HttpContext.Current.Request.IsLocal
};
ViewEngines.Engines.Insert(0, engine);
// StartPage lookups are done by WebPages.
VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
}
}
var viewsPath = Path.GetFullPath(@"..\..\Views");
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var service = new EmailService(engines);
I'm not technically running the Postal code outside of ASP.NET, however, the views do not exist as .cshtml files on disk and instead are precompiled into the shared DLL. I need to somehow tell Postal how to use these precompiled templates versus trying to find them on disk (as detailed by the above code sample). I've tried to pass the same engine created by the RazorGenerator code to the Postal.EmailService constructor, but that didn't work. I also tried using ViewEngines.Engines but no luck.
I'm trying to integrate Postal with precompiled views generated by RazorGenerator, but I am not having any success. I am using RazorGenerator and Postal in a shared DLL to isolate all email logic in my codebase. I have two ASP.NET apps that use this shared DLL to send emails. RazorGenerator auto generates the following code and configures it to run when the application is started:
This code is very similar to the code that is required to run Postal outside ASP.NET:
I'm not technically running the Postal code outside of ASP.NET, however, the views do not exist as
.cshtml
files on disk and instead are precompiled into the shared DLL. I need to somehow tell Postal how to use these precompiled templates versus trying to find them on disk (as detailed by the above code sample). I've tried to pass the same engine created by theRazorGenerator
code to thePostal.EmailService
constructor, but that didn't work. I also tried usingViewEngines.Engines
but no luck.Any ideas on how I might solve this issue?