Render Partial and Render Action are very different in their behavior with performance implications to each. Render Partial is just including a view, there is no controller processing that happens and it's very similar to server side includes (albeit more
powerful). RenderAction actually invokes the entire asp.net mvc runtime, meaning routnig, controller action methods and finally the view. RenderAction works well for some situations but overusing it can result in a performance hit.
@Html.Partial will not hit the controller (hence the breakpoint not firing). It simply loads the view directly and displays it inline. This is good for templating situations, but if you need to pull data or do some processing server side, then you need to
call RenderAction.
It sounds like your view is getting html encoded, hence the html showing up in the browser end view. What does your action method look like ? The one being called from RenderAction? Can you post that code? It should just be returning a view as you normally
would.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: How To Render A Partial View In Razor
May 01, 2012 05:11 PM|LINK
Render Partial and Render Action are very different in their behavior with performance implications to each. Render Partial is just including a view, there is no controller processing that happens and it's very similar to server side includes (albeit more powerful). RenderAction actually invokes the entire asp.net mvc runtime, meaning routnig, controller action methods and finally the view. RenderAction works well for some situations but overusing it can result in a performance hit.
@Html.Partial will not hit the controller (hence the breakpoint not firing). It simply loads the view directly and displays it inline. This is good for templating situations, but if you need to pull data or do some processing server side, then you need to call RenderAction.
It sounds like your view is getting html encoded, hence the html showing up in the browser end view. What does your action method look like ? The one being called from RenderAction? Can you post that code? It should just be returning a view as you normally would.
Blog | Twitter : @Hattan