Fall in love with mvc~ in views of multi-level folder ~ Continue ~ Division Page Support

Source: Internet
Author: User

Back to Catalog

Previously written an article, mainly for the view view, it can be placed in the N-level directory, it does not have to be in the views/controller/action of this relationship, and in the course of the program, it is found that the paging view does not support this feature, the reason is very simple, In Razorviewengine there are different belong to modify these two things, for the view of the lookup, defined by Viewlocationformats, and the partial view of the lookup is defined by Partialviewlocationformats, They define the query scope of the view, such as ~/views/lindadmin/{1}/{0}.cshtml, which can be represented in the directory under Lindadmin under Views.

Multi-level directory structure for partial pages

  /// <summary>    ///Background Routing/// </summary>     Public classAdmin_routing:razorviewengine { Publicadmin_routing () {//View LocationViewlocationformats =New[]            {              "~/views/{1}/{0}.cshtml",                "~/views/lindadmin/{1}/{0}.cshtml"//Customizing the car sales attempt            }; //Partial View LocationPartialviewlocationformats =New[]            {              "~/views/{1}/{0}.cshtml",                "~/views/lindadmin/{1}/{0}.cshtml"//Customizing the car sales attempt            }; }                Public OverrideViewengineresult Findview (ControllerContext controllercontext,stringViewName,stringMastername,BOOLUseCache) {            return Base.        Findview (ControllerContext, ViewName, Mastername, UseCache); }         Public OverrideViewengineresult Findpartialview (ControllerContext controllercontext,stringPartialviewname,BOOLUseCache) {            return Base.        Findpartialview (ControllerContext, Partialviewname, UseCache); }    }

We see in the code above the Findview and Findpartialview two methods, they are the way to look at when rendering the view, that is, your action to render which view, we can put our own logic to rewrite in these two

Method!

Look at the general background of the project, the background of some of the view is put into the lindadmin, and this is to be packed into consideration, which specific project hope to use the background, direct NuGet installation can, side page do not have to do, haha!

Back to Catalog

Fall in love with mvc~ in views of multi-level folder ~ Continue ~ Division Page Support

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.