Strangenut

ASP.NET MVC 2 and Html.RenderAction not working in Visual Studio 2010 Beta

So this week I've been working on an ASP.NET MVC 2 application and am using VS2010 Beta, and was stumped when Html.RenderAction() didn't exist!  Documentation everywhere indicates that it did in fact become part of the main MVC product, but why does it not exist? 

Well, it does, but it appears to have been moved... though I am not quite sure why this hasn't been documented or even yet referenced anywhere online.

At first I had registered the Microsoft.Web.Mvc namespace in my web.config.. nothing..

Registered, imported and otherwise used fully qualified paths to Microsoft.Web.Mvc directly in my Master page.  Still nothing.

After 2 days of digging around for this, and coming up empty handed... I went to the source.. CodePlex.

I downloaded the source for ASP.NET MVC 2 Futures and did a solution-wide search for RenderAction, and found it in the ViewExtensions class in the Microsoft.Web.Mvc namespace. Formerly, the method signature was Html.RenderAction("Action", "Controller",somethingElseHere)

Now it seems to require an HtmlHelper object to be passed in as the first argument... so, I've found that I needed to call it like this:

<% ViewExtensions.RenderAction(this.Html, "Menu", "Nav", new { highlightCategory = ViewData["CurrentCategory"] }); %>

 

Et voila!


Posted Jan 21 2010, 11:29 PM by dacrowlah
Powered by Community Server (Non-Commercial Edition), by Telligent Systems