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