RenderPartialToString missing in ASP.NET MVC

by Miha Markič 30. April 2009 12:57

If I had to pick the most important feature that is missing from ASP.NET MVC it would be RenderPartialToString. This method should render a partial view to a string and not to internal result. Why? Simple, when you have to do with AJAX and partial updates it is convenient to pack one ore more partial results into a JSON among with other related data.

So, RenderPartialToString would be my most important feature missing in ASP.NET MVC. Luckily ASP.NET MVC is very extensible and Kevin hacked up a solution. Make sure you also read the comments, specially one from Jon Kruger (where he fix a bug or two) and one from Kyle Simpson (where he describes a workaround around setting a proper content type).

Implemented all the code and fixes mentioned above I am able to return a JSON object containing more than one partial result and related data. But still, this looks like a hack and performance might be a problem (or not, no idea – did anybody check it out?). Anyway, I really hope that we’ll see RenderPartialToString in a future version or, even better, in a service pack – as soon as possible that is.

And of course, I've enhanced my strong typed views template with Render[PartialView]ToString strong typed methods as well.

Tags:

asp.net mvc

Pingbacks and trackbacks (1)+

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Miha Markic

About me
Righthand
 
Microsoft MVP
 
Developer Express' DXSquad
INETA Country Leader for Slovenia
INETA Country Leader for Slovenia

Slovene Developer Users Group Lead
Friends of Red-Gate
LLBLGenPro Partner

Miha currently works as a free lance consultant and software developer specialized in .net area.
He graduated in Computer and information science at the University of Ljubljana, Slovenia. He has accumulated experience in various programming languages such as Java, Visual Basic 3-6 (MCP), Visual C++, Delphi, C# and VB.Net through years.
He has experience in practically all (technical) stages of project development, including planning, framework development, user interface, business processes, as well as testing and documenting. He has worked on big and small projects in Slovenia and abroad (e.g. participated in completing level 3 IS for the Nucor steel plant, Hertford, USA).
Currently he enjoys programming in .net environment using C#. Since 2000 he has been active in Developer Express' DX Squad and has been ECDL trainer and tester. He also gives lectures on conferences and other events in Slovenia.

Month List

Tag cloud

Most comments

Paulius Paulius
1 comments
us United States
Meh Meh
1 comments
us United States
bart dm bart dm
1 comments
nl Netherlands

RecentComments

Comment RSS