Friday 21 February 2014

IIS7 not serving pages (ASPX) but just displays a blank page

I created a new IIS website with ApplicationPoolIdentity as the identity and .NET framework set to v4.0. In my hosts file I set my localhost to point to my test.dev domain (127.0.0.1 test.dev). When I tried viewing the site all I got back as a blank page.

What I tried: 

1. Installing all IIS components as I thought I might have missed some - this didn't help
2. Add full control permissions to my web folder for the ApplicationPoolIdentity (http://stackoverflow.com/questions/7334216/iis7-permissions-overview-applicationpoolidentity) - this didn't help
3. Registered .NET 4 with this command: C:\Windows\Microsoft.NET\Framework\v4.0.30319 C:\Windows\Microsoft.NET\Framework\v4.0.30319> aspnet_regiis.exe -i - This WORKED!!!

Wednesday 12 February 2014

Umbraco render macro within macro

I wrote this helper method to easily render macros within other macros when using razor (cshtml) views. This also allows the passing in of parameters. This is an alternative to RenderMacroContent which didn't seem to work for me.

public static string RenderMacro(string alias, int nodeId, Dictionary<string string=> parameters)
        {
            var macroEngine = new RazorMacroEngine();
            var macro = new MacroModel();
            macro.ScriptLanguage = "cshtml";
            macro.ScriptName = alias + ".cshtml";

            foreach (var parameter in parameters)
            {
                macro.Properties.Add(new MacroPropertyModel(parameter.Key, parameter.Value));
            }

            return macroEngine.Execute(macro, new umbraco.NodeFactory.Node(nodeId));
        }


This is the code that wasn't working:

umbraco.library.RenderMacroContent(string.Format("</?UMBRACO_MACRO>", alias, args), model.Id)