How to display partial view in asp.net mvc 2 using Controller and Action?
<body> <div id="header"> <div class="title">SPORTS STORE</div> </div> <div id="categories"> <% Html.RenderAction("Menu", "Nav"); %> </div> <div id="content"> <asp:ContentPlaceHolder ID="MainContent" runat="server" /> </div> </body> This is sample code from Stephen Sanderson's ASP.NET MVC Framework.
This code works with MVC V1 and MvcContrib. What it does, it displays a "Menu ()" view of the "Nav: Controller". Since ASP.NET MVC V2 includes the Partial () and RenderPartial () functions, I tried to implement it, but this code does not work. I tried to change it in several ways, but there seems to be no overload function that displays partial views, taking as parameters: 1) Controller name 2) View name
I am sure that I am not the first person to implement RenderAction () in this way, so there should be a workaround. Please, help.
I found a problem. I always delete the route {controller} / {action} and configure all my routes with lowercase REST, such as URLs. But for Html.RenderAction, you need to have such a common route. I added that the general route to the end of the list of routes, and it worked. - Mahdi February 22 at 14:42
Although I still donโt understand how this exactly works, why route tracing is important and what are the limitations of the route. Perhaps I will do some research later.