Recommended way to reuse html server-side

I thought using @Html.Partial calls other views on the server side, BEFORE passing the page to the user's browser...not asynchronously.

I have some very tiny views that are called in many views, example:


<div ="logo">
    <h2>This is my logo</h2>
    <img src="logo.jpg"/>

Wouldn't it be inefficient to create a async GET request just for that small partial? Is there a way to reuse html server side, before passing the rendered page to the user?


Your question implies it's possible to call views(partials) AFTER the page is sent to the client (a single request here, not ajax), which is not possible.

Html.Partial(), Html.RenderPartial(), Html.RenderAction() and Html.Action() are executed DURING the streamwriter (networkwriter?) is streaming content to the client. All four are NOT async (as even if they were called via async methods, the rendering is still on hold until the calls are complete, nullifying the point of async). The difference between Render and a Non-Render action is how the content is delivered to the stream..

As async is not an option, You're best options are:

For each view use Html.RenderPartial().

Or for a more complex semi-nasty, barely better performance, call Html.Partial(), store it (HttpApplication... yeesh), and use that as a cache. (Really, just don't do this, it will make the code terrible to maintain).

Need Your Help

Check if button is active

javascript jquery

I'm really struggling with this piece of code.