ASP. @Html. @Html. Action @Html. renderpartial @Html. Renderaction differences

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.