MVC3 has been learning, the project sometimes will be used, blog park has been wandering, want to write something, but I am usually lazy, the theoretical level of things they do not write, or to point to the actual simple entry of the blog, to their own summary of the ability is a promotion, of course, also hope that the people have not used the region has helped.
Why do we have a zone?
MVC itself advocates the separation of concerns, controller control business logic, the model is used to read data, depending on the display display page, so whether for developers themselves or for later maintenance project developers are very good, can open familiar with the project business, and not like the hierarchy is not clear, code is not standard, A logically chaotic project that boosts development efficiency. But when the business logic of the project itself is complex enough, if all the business logic is written under the Controller folder, you will see a very large variety of named controllers, this time the role of the area is displayed, you can a business logic corresponding to a folder, very practical , simple and clear.
How do I write an area?
Right-click your own MVC project, add-zone, write your own zone name, and the result is as follows:
The generated login folder under areas, and help us generate a LoginAreaRegitrations.cs class file, what is the role of the next, the first set up Logininfo controller to see the effect:
How do I handle domain controller names?
If you set up a home controller under the Controller folder under the zone controllers, if there is also a home control controller this time will conflict if:
The solution is simply to add a controlled namespace to the Registerarea method in the LoginAreaRegitrations.cs that we saw just now in the area control.
It is also possible to add a corresponding namespace at the relative routing location by a different name.
The code itself is very simple to write, really if written blog or need to take some time, contact is quite a lot of things, the advanced of their own at present can not write, their own nothing to write the basics of things, exercise their own at the same time also hope to help everyone ~ Monday good mood ~