Anders I tried the same thing a couple weeks ago and ended up giving up and going about it another way. I'm interested to know if something like this can work. My conclusion at the time was that I didn't have time to experiement :)
I have now had some time to investigate this futher. It turns out that there is no problem calling an XSLT- or .NET usercontrol based macro.I have also tried to embed my Razor-macro in a .NET usercontrol, but still no luck. No matter what i do with my Razor-macro I get an "Error loading MacroEngine script".
Therefore it seems that there is a problem with the MacroEngine for Razor combined with the umbraco.library.RenderMacro method.
I think i will just write an XSLT instead - must be something for the ongoing pillow-fight between the XSLT-lovers and the Razor-rebellion? :-)
Load content from a (Razor-) macro through an ASP.NET generic handler
Hi
I have a generic handler and i want to load content from a macro. I am trying with the following piece of code:
context.Response.Write(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"smallCart\"></?UMBRACO_MACRO>", 1051));
(don't mind the hardcoded ID for now)
When i hit the handler from my browser, it gives me "Error loading MacroEngine script (file: SmallCart.cshtml)"
If i place the exact same code in an ASP.NET masterpage or an ASP.NET usercontrol:
ltrTest.Text = umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"smallCart\"></?UMBRACO_MACRO>", 1051);
(outputting it to an ASP.NET literal control for testing)
it runs my SmallCart.cshtml razor-script and outputs the result just fine.
Does this relate to something about different contexts between an ASP.NET page and the generic handler... or any other good suggestions?
Regards
Anders
didn't try it yet. but i found this thread, maybe it will help you http://our.umbraco.org/forum/developers/xslt/16364-Any-possibility-of-combine-XSLT,-Python-and-Razor-Eg-Macro-within-Macro
Anders I tried the same thing a couple weeks ago and ended up giving up and going about it another way. I'm interested to know if something like this can work. My conclusion at the time was that I didn't have time to experiement :)
Hi Eran and Anthony
Thank you for your answers. I have had a look at Eran's link and i have been trying to figure this out since my post, but with no success :-(
I will try to ask at the upcoming Umbraco Codegarden 11. Of course i will post the solution if it exists.
Regards
Anders
Hi again
I have now had some time to investigate this futher. It turns out that there is no problem calling an XSLT- or .NET usercontrol based macro.I have also tried to embed my Razor-macro in a .NET usercontrol, but still no luck. No matter what i do with my Razor-macro I get an "Error loading MacroEngine script".
Therefore it seems that there is a problem with the MacroEngine for Razor combined with the umbraco.library.RenderMacro method.
I think i will just write an XSLT instead - must be something for the ongoing pillow-fight between the XSLT-lovers and the Razor-rebellion? :-)
Maybe you could try macroEngine.Execute on the razor script instead http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more
Hth / Jonas
is working on a reply...