RenderAction in Preview 5http://forums.asp.net/t/1313421.aspx/1?RenderAction+in+Preview+5Tue, 02 Sep 2008 05:25:09 -040013134212591679http://forums.asp.net/p/1313421/2591679.aspx/1?RenderAction+in+Preview+5RenderAction in Preview 5 <p>&nbsp;In the previous&nbsp; Preview 4 there was a bug about renderaction that couldn't be called with strings but only with typed parameters like:</p> Html.RenderAction&lt;MessagesController&gt;(x =&gt; x.Index(messageParameters)); // This worked<br> <p>Html.RenderAction(&quot;Index&quot;, &quot;MessageController&quot;, messageParameters); // This gave stackoverflow</p> <p>In preview 5 seems that RenderAction with string parameters work again with no errors.</p> <p>I still have a problem as my called controller is correctly called but it doesn't get the parameters and I think this could be a problem in my code more than a new bug.</p> <p>So:</p> <p>1) I have an helper methods that render a series of partial views calling the RenderAction method like:</p> <p>public static void RenderWidgets(this HtmlHelper helper, PageViewData pageData) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach(WidgetViewData module in pageData.Modules) {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; helper.RenderAction(module.ModuleMethod, module.ModuleName, module);</p> <p>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; }</p> <p>} </p> <p>where ModuleMethod could be a string like &quot;Index&quot; for calling the action in the controller and ModuleName is the name of the controller.<br> The third parameter is the actual module data and I verified with the debugger that at the moment of the call of the method the data is there.<br> <br> </p> <p>2) My Controller, say MessageController is correcly called as it's method but the parameter is null...</p> <p>&nbsp; public class MessagesController : Controller<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ActionResult Index(WidgetViewData widgetParams)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //some controller stuff<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return View(&quot;~/Views/Widgets/Messages.ascx&quot;, widgetParams);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br> &nbsp;&nbsp;&nbsp; }</p> <p>Where is the problem and what am I doing wrong?<br> </p> 2008-08-31T20:19:16-04:002594094http://forums.asp.net/p/1313421/2594094.aspx/1?Re+RenderAction+in+Preview+5Re: RenderAction in Preview 5 <p>&nbsp;Ok I finally found the problem.</p> <p>I changed the call:<br> </p> <p>helper.RenderAction(module.ModuleMethod, module.ModuleName, module); <br> </p> <p>&nbsp;in</p> <p>helper.RenderAction(&quot;Index&quot;, module.ModuleName, new {mod = module}); </p> <p>and now the object get passed correctly.</p> <p>&nbsp;</p> 2008-09-02T05:25:09-04:00