2

I just asked a question about use of these. They were suggested to me as a means to include text ( paragraphs of text ) into a web page. VERY STATIC text that I don't want to fill up the view with.

My question is. Which of these two should I use and also is there an overhead to using them. I thought views were compiled just once. How about if I include these files. Does that mean that every time I view a page then it has to go get the file.

Robert Dawson
  • 153
  • 1
  • 2
  • 10

1 Answers1

4

Firstly, have a read through Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction and then you can read this post, http://5pm.zwares.com/post/1172669451/asp-net-mvc-performance-html-renderpartial-vs

in summary, the post contains this bit of useful information from Phil Haack

Html.RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html.Action returns a string with the result.

Community
  • 1
  • 1
Pieter Germishuys
  • 4,828
  • 1
  • 26
  • 34
  • I tried the following: Line 116: @if (Model.RowKey == "Objectives") { Line 117: @{Html.RenderPartial("objectives.cshtml");} Line 118: } but this give me an error: No overload for method 'Write' takes 0 arguments – Robert Dawson Jun 30 '11 at 06:06
  • It's because you don't put a block of code in a block of code. It should look like `@if (Model.RowKey == "Objectives") { Html.RenderPartial(""); }` Instead of what your code probably looks like `@if (Model.RowKey == "Objectives") { @{Html.RenderPartial("");} }` – Erik Philips Jan 05 '15 at 21:55