Monorail MVC application (2)-build multi-layer application

Source: Internet
Author: User

I am used to hierarchical. NET development. Of course, it also has an advantage in layering. Therefore, when using monorail for website construction, the first consideration is how monorail can cope with the layered structure.
Problem 1: monorail does not have a root directory on the web layer and must have a directory for views
Monorail MVC does not have a root directory structure, that is, it can only access one level-2 Directory, such as http://www.pumaboyd.com/views#/#, and all its contents are stored in the viewsdirectory. At first, I thought this was a very serious problem, and such restrictions were very restrictive. Later in firstyiArticleThis section describes how to configure it to the root directory. In fact, you will find that you can solve this problem through routing. And I still think the routing method is the best.
You can also change the default views Directory, which can be configured through webconfig.

<Viewengine viewpathroot = "wap3" customengine = "Castle. Monorail. Framework. Views. nvelocity. nvelocityviewengine, Castle. Monorail. Framework. Views. nvelocity"/>

In this way, the default directory is changed to wap3.

Question 2: The CS file corresponding to the Controller.
If it is the default value, it will be in the controllers Directory, which I do not want to see. In this way, the entire web layer has a DLL. So we need to configure it to a separate layer (in a separate project)
Add an independent project, which is similar to the configuration in webconfig.

<Assembly> webhome. Control </Assembly>

It also supports multiple controllers. It depends on the application of your project. If necessary, you can split it into more details.

<Assembly> webhome. Control </Assembly>

<Assembly> webhome. control1 </Assembly>

<Assembly> webhome. control2 </Assembly>

The remaining service, BLL, and DAC layers have little change with the original structure. In fact, the last step is to split the current web layer into V and C

Demo diagram (the structure of the image is always better than that of the text .)

    • Webhome is the page, that is, the MVC v
    • Controls is the display control class of the page, that is, the MVC C
    • Service & DAC is the specific page logic and data access layer (whether it is MVC m is not suitable, I feel that I am downplaying the concept of m)
    • Component is some components of the page, which is equivalent to webcontrol

ReturnMonorail MVC application

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.