These three different features exist in the Razor view engine and can be used to achieve similar results. In the end all three of them just render pieces of HTML code, but the way to define and use them is fairly different. I know that:
Html Helpers are created as extension methods for the HtmlHelper
class. They frequently use the TagBuilder
class to generate some HTML and always should return an IHtmlString
.
Razor Helpers (@helper
methods) can be defined locally (in the same razor file) or globally (in the App_Code
directory). They are small snippets of HTML code that can be reused exclusively in Razor files.
And finally, Partial Views are just regular view files that can be included in other view files using the @Html.Partial
helper.
My question is:
Is there a specific scenario for each one of these features? Or it comes down to different flavors to achieve the same result?