Skip to content

Instantly share code, notes, and snippets.

@dalion619
Created August 26, 2018 18:17
Show Gist options
  • Save dalion619/00f647e12887e5e4e2092a62427fe169 to your computer and use it in GitHub Desktop.
Save dalion619/00f647e12887e5e4e2092a62427fe169 to your computer and use it in GitHub Desktop.
RazorEngine TemplateServiceConfiguration
// Path needed for the ability to call this project in an ASP.NET project.
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
var codeBaseUri = new UriBuilder(codeBase);
var uriPath = Uri.UnescapeDataString(codeBaseUri.Path);
var dirPath = Path.GetDirectoryName(uriPath);
// ResolvePathTemplateManager with no caching.
_razorEngineService = RazorEngine.Templating.RazorEngineService.Create(new TemplateServiceConfiguration
{
TemplateManager = new ResolvePathTemplateManager(new[]
{$@"{dirPath}\EmailPartialViews", $@"{dirPath}\EmailViews"}),
DisableTempFileLocking = true,
CachingProvider = new DefaultCachingProvider(t => { })
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment