GetLocalResourceObject with NVelocity
-
03-07-2019 - |
Question
How can I load a .resx file with GetLocalResourceObject when using NVelocity? I'm using ASP.NET MVC with mvccontrib nvelocity viewengine and sharp-architechture.
I've hardcoded every possible virtualpath I could think of (eg. ~/Home/index.vm.resx) but everyone fails. I've also tried with ExpressionBuilderContext.
Solution
Where are you calling GetLocalResourceObject? Calling it from a controller action will not work, because an action has no real association to any view file (e.g. /Home/Index.vm). A local resource will only work from within the actual view (/Home/Index.vm
).
Also, make sure the .resx files are placed within App_LocalResources folders in each of the "view folders" (e.g. /Home/
)
- /Views/Home/Index.vm
- /Views/Home/App_LocalResources/Index.vm.resx
Hope this was of some help Anders, if not, buzz me on Messenger ;-)