In ASP. net mvc, @ Html. Partial, @ Html. Action, @ Html. RenderPartial, @ Html. RenderAction,
1. View of the Action and RenderAction loading method, perform the order of Controller → Model → View, and then bring the generated page back to the original View before returning it. While Partial and RenderPartial directly load the View File Content
2. Html. Partial can be directly supplied to the user control name as a parameter, while Html. Action must have a corresponding Action, and PartailResult (retun PartialView () is returned within the Action ()).
3. Html. Partial is recommended for simple user controls without any logic. Html. Action is recommended for user controls that require some Model settings. Of course, the Html. Partial method can be applied to Model data. You can refer to the method for overloading.
4. What is the difference between Html. Partial and Html. Action? The difference is that Html. Partial has only one view, while Html. Action corresponds to an Action in addition to a view. Therefore, Html. Action is more powerful than Html. Partial.
How to call this Html. Partial
// 1. Use the view in the current folder by the view name (if not found, search for the Shared folder)
@Html.Partial(
"_test"
)
// Load the corresponding file/Views/Product/_ test. cshtml
// 2. Locate the view based on the application root path // use "/" or "~ The path starting with/"indicates the application root path.
@Html.Partial(
"~/Views/Product/_test.cshtml"
)
@Html.Partial(
"/Views/Product/_test2.cshtml"
)
// 3. Load view files from other directories
// Note: copy the web. config in views to the template directory. Otherwise, the view at "/template/A. cshtml" must be derived from WebViewPage or WebViewPage. <TModel>"
@Html.Partial(
"/template/A.cshtml"
)