@Umbraco.RenderMacro("myAlias") erroring with null reference
Hello all,
I have created a surface controller with a child action on it to use in a child action macro.
I'm using Umbraco 5
The surface control is not a plugin, it resides in a ~/Controllers folder within my project. I've suffixed the name with SurfaceController and inherrited from SurfaceController. I've also decorated my child action with the [ChildActionOnly] attribute.
When I create my macro in the umbraco back office it finds my Action and it is there to select in the dropdownlist of SurfaceControllers.Actions.
I then go to my Template still in the umbraco back office and insert the macro successfully via the editor. It inserts the following into my template:
@Umbraco.RenderMacro(
"populateViewBagWithSharedSettings")
When I run my project now it throws an errorr: Object reference not set to an instance of an object.
My SurfaceController doesn't actually render a view it just sets some values i'd like to be in the viewbag. Therefore my controllers return type is ContentResult.
If anyone could please help me with this error I'd much appreciate it.
If someone could tell me the proper way to just add something to the Viewbag that would be great to. I remember reading about some feature in umbraco I should be taking advantage of to do that but I can't remember what it was.
@Umbraco.RenderMacro("myAlias") erroring with null reference
Hello all,
I have created a surface controller with a child action on it to use in a child action macro.
I'm using Umbraco 5
The surface control is not a plugin, it resides in a ~/Controllers folder within my project. I've suffixed the name with SurfaceController and inherrited from SurfaceController. I've also decorated my child action with the [ChildActionOnly] attribute.
When I create my macro in the umbraco back office it finds my Action and it is there to select in the dropdownlist of SurfaceControllers.Actions.
I then go to my Template still in the umbraco back office and insert the macro successfully via the editor. It inserts the following into my template:
@Umbraco.RenderMacro(
"populateViewBagWithSharedSettings")
When I run my project now it throws an errorr: Object reference not set to an instance of an object.
The stack trace is:
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Cms.Web.Macros.MacroRenderer.RenderMacroAsString(String macroAlias, IDictionary`2 macroParams, ControllerContext currentControllerContext, Boolean isForRichTextEditor, Func`1 resolveContent) +284
Umbraco.Cms.Web.UmbracoHelper.RenderMacro(String alias, Object parameters) +151
ASP._Page_Views_Umbraco_clientSiteFrame_cshtml.Execute() in c:\Development\YourWebsiteV2\YourWebsite V2\Views\Umbraco\clientSiteFrame.cshtml:12
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +88
System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +102
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +12
System.Web.WebPages.WebPageBase.Write(HelperResult result) +67
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +66
System.Web.WebPages.WebPageBase.PopContext() +262
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
My SurfaceController doesn't actually render a view it just sets some values i'd like to be in the viewbag. Therefore my controllers return type is ContentResult.
If anyone could please help me with this error I'd much appreciate it.
If someone could tell me the proper way to just add something to the Viewbag that would be great to. I remember reading about some feature in umbraco I should be taking advantage of to do that but I can't remember what it was.
Thanks
Dean
is working on a reply...