rkrauter
rkrauter

Reputation: 1169

Why would want to get back a MvcHtmlString instead of writing to the response stream?

So I have read this question (Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction) and understand what Html.Partial and Html.Action do.

But I am trying to understand why these were introduced. Could you please explain a scenario where I would want to get back a MvcHtmlString instead of writing it out to the response stream? I am sure there is a big use case for this.

Thanks!

Upvotes: 0

Views: 223

Answers (1)

Alexander Prokofyev
Alexander Prokofyev

Reputation: 34523

Having MvcHtmlString gives you more flexibility. You may modify it before using or store it to avoid complex rerendering.

Upvotes: 1

Related Questions