Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC 3 Html.RenderPartial vs Html.Partial

This article states

There are some cases where you might like to step aside and write directly to the HTTP Response stream rather than having a partial view render the results (partials/views use MvcHtmlString/StringWriter)

Use Html.RenderPartial for streaming images or other elements that are media-centric or where faster download times are highly important.

What overhead does MvcHtmlString/StringWriter introduce? Are there downsides to using Html.RenderPartial all of the time, if there is less overhead?

I could not find answers on MSDN:

http://msdn.microsoft.com/en-us/library/ee402902.aspx

http://msdn.microsoft.com/en-us/library/system.web.mvc.html.renderpartialextensions.renderpartial.aspx

like image 646
Eric J. Avatar asked Mar 08 '12 19:03

Eric J.


People also ask

What is difference between HTML partial and HTML RenderPartial in MVC?

The primary difference between the two methods is that Partial generates the HTML from the View and returns it to the View to be incorporated into the page. RenderPartial, on the other hand, doesn't return anything and, instead, adds its HTML directly to the Response object's output.

What is the difference between HTML partial and HTML action?

Partial when you are rendering static content. Action Partial : Use Html. Action when handling dynamic Content/data.

What are the benefits of HTML RenderPartial over?

Use RenderPartial when you have a model to send to the view and there will be a lot of html that doesn't need to be stored in a variable. Use Partial when you have a model to send to the view and there will be a little bit of text that needs to be stored in a variable. RenderAction and RenderPartial are faster.

What is HTML RenderPartial in MVC?

RenderPartial(HtmlHelper, String) Renders the specified partial view by using the specified HTML helper. RenderPartial(HtmlHelper, String, Object) Renders the specified partial view, passing it a copy of the current ViewDataDictionary object, but with the Model property set to the specified model.


1 Answers

Html.RenderPartial is faster then Html.Partial because of RenderPartial give quick response to Output.

here are some reference:-

http://devlicio.us/blogs/derik_whittaker/archive/2008/11/24/renderpartial-vs-renderaction.aspx

What is the difference (if any) between Html.Partial(view, model) and Html.RenderPartial(view,model) in MVC2?

like image 84
Chinook Avatar answered Nov 15 '22 11:11

Chinook