ASP. net mvc-View

Source: Internet
Author: User

First of all, I would like to say that the view of ASP. NET MVC is not a simple page. It implements the iview interface.

Public   Interface Iview {
Void Render (viewcontext, textwriter writer );
}

In ASP. net mvc, a default view is provided, that is, webformview.

Then, the operations after the Web request arrives at the controller and the Controller returns the viewresult are like this:

    1. Viewresult itself executes the executeresult method. This method is the actionresult interface method, and viewresult is a class that implements this interface.
    2. Find the corresponding View
    3. Construct viewcontext
    4. Render
    5. Create viewpage
    6. Set the layout location

The main difference between viewpage (system. Web. MVC. viewpage) and the previous webpage (system. Web. UI. Page) is that the only and most important feature is page rendering. The viewstate, pageevents, and control hierarchies of webpage are discarded. SlaveCodeSee, viewpage implements the iview interface, and this interface has only one method, that is, render. It can be seen that its function is quite definite.

Viewengine is used to determine the view in MVC. That is, it is responsible for finding a specific view. The default viewengine is webformviewengine. If we want to change a view and do not want to continue using the ASPX page, we need to reconstruct a viewengine and register it in the system.

Layout is equivalent to masterpage. The difference is that it does not have the PostBack and form submission mechanisms. That is to say, it can only layout for viewpage.

Viewdata has already been mentioned before. View uses it to render the page. However, what we should say here is that a view only corresponds to a viewdata. If there are other partialviews In a view, the viewdata between them is not shared, the content is the same by default.

View also has some other knowledge, such as bindattribute and modelstate. I will study it again later. I feel a little confused when I encounter so many things for the first time.

Continue ......

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.