Use Taurus. MVC as an enterprise site (on) and taurus. mvc Enterprise
Preface:
I was planning to write an article titled Taurus. MVC from getting started to being proficient!
Later I thought about it. Let's set the tutorial on this enterprise site project !!!
Enterprise site style:
I posted a corporate website written by my sister-in-law: Recently I spent a few nights helping my sister build a corporate website.
Technical style: Text Database (txt) + WebForm
Transformation style: Text Database (txt) + Taurus. MVC
The main interface to be completed today is the Home Page:
OK. Let's start by looking at how to implement this enterprise project from scratch step by step:
1: Create an ASP. NET empty Web application project:
2: Add a class library project called Taurus. Controllers
3: Use Nuget to reference Taurus. MVC in the Taurus. Controllers project:
Of course, you can also use the source code project, or find the two DLL in the source code to add references:
Note that the EnterPriseSite project must reference the Taurus. Controllers project. After all, the compiled DLL should be concentrated on the EnterPriseSite project.
4. Add the Views folder and several blank pages to the EnterPriseSite project:
Default.html and other pages are not placed in the default folder, which is incorrect and will be corrected later.
5: Copy the text database under the Style and App_Data directories from the original WebForm project:
By the way, change the project name to EnterPriseSite. View.
6. Copy the HTML tag of the original user control to master.html in the shareddirectory:
When we use Taurus. MVC, we have the Repeater concept, only Html and JS.
If you have business-condition code, you can use JS for processing or background processing. Here, you can use Js for processing (the background processing is demonstrated later ):
Nodes on the template page can be randomly placed. As long as the node has a name (id or name), it can be referenced by other html.
The referenced attribute name can be id, name, or a tag such as (head, body, title, script, style, form, meta, link)
So you can use master. head, master, body, master. title, master. script (both take the first node only )...
7: copy the Default page tag from the original interface:
Original Default. aspx:
Default.html
The interface is complete. Now you have to write the code:
8: Create defacontroller controller. cs and Copy several table classes of CodeFirst:
After a Logic folder is created, you do not want to create too many projects when the project is simple. You can use folders:
Then, write several methods to load them to the corresponding html file:
Therefore, html is stored in the/views/default/directory.
Note:
The default access paths are: localhost/default/index, locahost/default/artilelist...
To remove the default route, I added the default route. In the past, there were only 1 and 2 routing modes, but now there were 0 more.
9: Check the Web. Config Configuration:
10: Write logic code binding page:
Because the project is simple, I directly created a class for the business logic and threw it into the Controller, called DefaultLogic.
To make the hierarchy clearer, you should create a new Taurus. Logic class library project.
The logic class must inherit from Taurus. Core. LogicBase to pass the View object to the logic class. Pay attention to the constructor.
Because the html node id is based on the conventions: the table name View, so Bind (View) can be, do not need to specify the name.
Here, an event View. Onforeach is added to format the time when the interface is rendered:
Of course, if the background is not well formatted, the foreground will handle it, just as one of the above Code is processed using JS.
11: The Controller calls the logic code to render the page:
Finally, a beautiful homepage is coming out:
After finishing the work:
Several subsequent pages, including the article list, article details, Product Center, background management, and the next part.
I used to write articles after the entire project was completed. Now I write half of the project. I need to add an article...
Partially completed Source: http://code.taobao.org/svn/cyqopen/trunk/Taurus.MVC.GettingStarted
Thank you for your support !!!