Note that there are some explanatory texts on larger screens.

plurals
  1. PONVelocity not finding the template
    primarykey
    data
    text
    <p>I'm having some difficulty with using NVelocity in an ASP.NET MVC application. I'm using it as a way of generating emails.</p> <p>As far as I can make out the details I'm passing are all correct, but it fails to load the template.</p> <p>Here is the code:</p> <pre><code>private const string defaultTemplatePath = "Views\\EmailTemplates\\"; </code></pre> <p>...</p> <pre><code>velocityEngine = new VelocityEngine(); basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, defaultTemplatePath); ExtendedProperties properties = new ExtendedProperties(); properties.Add(RuntimeConstants.RESOURCE_LOADER, "file"); properties.Add(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, basePath); velocityEngine.Init(properties); </code></pre> <p>The basePath is the correct directory, I've pasted the value into explorer to ensure it is correct.</p> <pre><code>if (!velocityEngine.TemplateExists(name)) throw new InvalidOperationException(string.Format("Could not find a template named '{0}'", name)); Template result = velocityEngine.GetTemplate(name); </code></pre> <p>'name' above is a valid filename in the folder defined as basePath above. However, TemplateExists returns false. If I comment that conditional out and let it fail on the GetTemplate method call the stack trace looks like this:</p> <pre><code> at NVelocity.Runtime.Resource.ResourceManagerImpl.LoadResource(String resourceName, ResourceType resourceType, String encoding) at NVelocity.Runtime.Resource.ResourceManagerImpl.GetResource(String resourceName, ResourceType resourceType, String encoding) at NVelocity.Runtime.RuntimeInstance.GetTemplate(String name, String encoding) at NVelocity.Runtime.RuntimeInstance.GetTemplate(String name) at NVelocity.App.VelocityEngine.GetTemplate(String name) ... </code></pre> <p>I'm now at a bit of an impasse. I feel that the answer is blindingly obvious, but I just can't seem to see it at the moment.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload