View engine for MVC4

Source: Internet
Author: User

1.MVC returns the view, the result is the Viewresult type

2.MVC the Executeresult method that returns the result is executed when the return result is executed

Here ActionResult is an abstract method, executed, will execute the rewritten method, that is, the viewresultbase Executeresult method;

As you can see, when you finally return to the view, Findview () is called, because this is an abstract method, the last call is the Findview () method in the ViewResult of Return view (), and the return value is Viewengineresult

3. Return to Viewengineresult, get the view engine, the view engine contains the found view (view property)

The front is just a simple process, if you do not see clearly, you can check against reflector, followed by the theme, MVC view default load Path 1. As you can see from the front, the view engine is mainly iviewengine this interface

There are mainly two view engine subclasses, and this is what we are familiar with razor and WebForm

Let's take a look atthe Razorviewengine constructor

Does it look familiar, this is the "Default view path" That MVC gives us, and if you want to create a new custom folder for yourself, MVC can automatically go inside to find the corresponding view:

1.

2. Clear the default engine, add your own definition of the engine, in the search for the view can be based on a custom folder to find the

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.