After the database is created, we can develop it.
1. Create a bookshop ASP. net mvc Web Application
2. Select not to generate the test project (we need to manually create a test later ).
3. generate the following solution
4: We use the default MVC structure. The model mainly provides data and the controller mainly implements business logic. The view is mainly used to interact with users (the figure below is from scottegu)
5. We plan to access our functions in the following path (we use the Administrator's use case for example)
URL format |
Action |
URL example |
/Category/List |
Browse all books |
/Category/List |
/Category/edit/ID |
Edit a category |
/Category/edit/1 |
/Category/delete/ID |
Delete A category |
/Category/delete/2 |
6. next, we will create a master page for the Administrator. The master page is a shared page, that is, used by multiple pages. Therefore, we will put it in the views/shared directory and modify the default site. MASTER:
<% @ Master language = "C #" autoeventwireup = "true" codebehind = "site. master. cs" inherits = "bookshop. Views. Shared. Site" %> <! Doctype Html Public "-// W3C // dtd xhtml 1.0 strict // en" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < Html Xmlns = "Http://www.w3.org/1999/xhtml" > < Head Runat = "Server" > < Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = iso-8859-1" /> < Title > Book Shop </ Title > < Link Href = "Http://www.cnblogs.com/Content/Site.css" REL = "Stylesheet" Type = "Text/CSS" /> </ Head > < Body > < Div ID = "Header" > < Ul > < Li > < A Href = "Category/List" > Category </ A > </ Li > < Li > < A Href = "Author/List" > Author </ A > </ Li > < Li > < A Href = "User/List" > User </ A > </ Li > < Li > < A Href = "Comment/List" > Comment </ A > </ Li > < Li > < A Href = "Order/List" > Order </ A > </ Li > </ Ul > </ Div > < Div ID = "Content" > < ASP: contentplaceholder ID = "Maincontentplaceholder" Runat = "Server" > </ ASP: contentplaceholder > </ Div > </ Body > </ Html >
7. Modify site.css to the following content:
CSS
# Header
{
Width : 100% ;
Margin : 0px ;
Padding : 5px ;
Border : 0px ;
Border-bottom : Solid 1px #000 ;
}
# Header ul
{
List-style-type : None ;
}
# Header ul Li
{
List-style-type : None ;
Float : Left ;
Margin : 5px ;
}
. Clear
{
Clear:Both;
}
8. Now, the Administrator's master page is complete.
9. The interface is relatively simple, and we will gradually beautify it later.