asp.net mvc is finally waiting for the new version, this time it is still preview version. There are a number of new features added to this version. Especially in the management of Viewengine. It has been greatly improved, not only to make it easier for users to replace Viewengine, And it's possible to use multiple viewengine in a single system, and this article explores how Viewengine works in the new and older editions and compares them, and then shows how to add one or more viewengine and let them work interactively.
First of all, the next P5 to viewengine improvements, in the old version, the system involves viewengine management has two interfaces, respectively: Iviewengine, Iviewlocator, where the ivewengine responsible for rendering view, Iviewlocator is responsible for the path handling of the view. At the same time, in the controller to select Viewengine, so that when the implementation of the viewengine passed to the Viewresult, Finally Viewresult uses Viewengine to render the UI. The old version of the View section is outlined below:
Its execution flow is roughly as follows: The MVC framework finds the corresponding controller based on routing data, and controller Initializes a viewengine based on iviewlocate (Iviewlocater is generally used for path selection) It then executes the controller Execute method, which performs the action indirectly through the Controlleractioninvoker, and each action returns a ActionResult object, and then It executes the ActionResult Executeresult method. The system has many kinds of actionresult, when the ActionResult is Viewresult, Controller will pass on the viewengine of your viewresult and eventually use Viewengine to render the data in Viewresult.