reproduced from: "ASP. @Html. @Html. Action @Html. renderpartial @Html. Renderaction differences"
Copy it over first.
The return value of the method with render is void, output inside the method, and the return value type without render is mvchtmlstring, which is a string.
Partial and RenderPartial: Loads the contents of the view file directly, action and Renderaction: re-executes the order of the Controller→model→view, then returns the resulting page back to the original view.
Partial and RenderPartial: The user control name can be supplied directly as a parameter; action and renderaction: a corresponding action is required to return partialresult within the action (that is, return Partialview ()).
For simple user controls without any logic, partial is recommended, and action is recommended for user controls that need to be set up with some model.
Another benefit of using html.action is that you can choose different user controls depending on the scene when you return Partialview.
At that time used to @html.action be played. Then I found the article above. It feels good to write. There is a contrast. Easy to understand
In fact, what they have in common is very similar to the previous Incloud, which is to load files or values elsewhere into the current page.
The difference is in the application process. If the file needs to be calculated internally. Need to pass a parameter. Need to call the database and other utility model: It is distinguished by the use of:
It 's important to note that
Action and Renderaction: Re-execute the order of the Controller→model→view, then return the resulting page back to the original view.
This sentence. It means that. If you are in the loaded page: The value of layout is not modified ... The result of the output is likely to surprise you. Because of the error.
Or the value of the file you call is populated with the @renderbody () of your master page.
So it's recommended to write layout=null in front of this file.
ASP. @Html. @Html. Action @Html. renderpartial @Html. Renderaction differences