Learning Notes (ii)--MVC extension (render view)

Source: Internet
Author: User

How do I render a view?

I take a look at the near view engine as an example, the near-Themedviewengine class is the rewritten view engine. The Themedviewengine class mainly rewrites the two methods of Findpartialview and Findview. The positioning of the View,partialview and layout is also rewritten. (HTTP://C.JINHUSNS.COM/CMS/C-3256/?TYPE=XCJ)

This is the Findpartialview method, which is to look up the distribution page and render it and display it.

Presentareakey renders the zone ID, isapplication whether it is an app.

Setting related property annotations on a controller

By looking at this method, it is possible to know that it has two output parameters, one string is the render area ID, and the other is an application of type bool.

The next step is to determine if the application

1. If yes

Get areaname by routing data first, and then treat it as an argument. Passed to the Getviewpathofapplication method.

The address path of the view matches the near-directory structure. This method is to get the view path in the application module

2, if not the application

The Getrequesttheme method of the Themeservice class is called first to get the skin appearance entity. The Themeservice class is the skin business logic class, which gets the skin appearance entities in this

The Getviewpathoftheme method and the Getviewpathofapplication method are basically similar, but their addressing paths are not the same. The skin has an inheritance relationship.

1. Getviewpathoftheme method

When we get what we need, we give it to Themedrazorview and let it activate the view for us.

2, Themedrazorview class

The rendering mechanism of view embodied in MVC through Razorview/webformview is finally embodied in the activation of the Webviewpage object. The Themedrazorview class is the rewritten Razorview. Themedwebviewpage inherits the Webviewpage, so we're going to activate themedwebviewpage here.

The purpose of the Themedwebviewpage class rewrite is to allow him to support our skin mechanism.

The Getlayoutpathoftheme method is similar to Getviewpathofapplication and is only a different addressing path.

1. Getlayoutpathoftheme method

If you want to load your own written view engine, just two steps in the Application_Start method:

1. Clear the original view engine. 2. Add your own view engine. Reprinted from: HTTP://C.JINHUSNS.COM/CMS/C-3256/?TYPE=XCJ

Learning Notes (ii)--MVC extension (render view)

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.