1. url ing to Controller actionresult (method)
(1) Add storecontroller
Public Class Storecontroller: controller { // // Get:/store/ // Public actionresult index () // { // Return view (); // } Public String Index ( String Name) // Understand how URLs correspond to Controllers { Return Httputility. htmlencode ( " Welcome, " + Name + " ! " );// Store/index? Name = Admin } Public String Browse ( String Genre ){ Return Httputility. htmlencode ( " You're browsing Genre " + Genre ); // Store/browse? Genre = jaze } Public String Details ( String Album ){ Return Httputility. htmlencode ( " This is the detail " + Album ); // Store/details? Album = love in the West Region }}
(2) modify the registerroute method of globe. asax to make storecontroller index the default homepage.
(3) understand how a URL corresponds to a method in the controller:
2. The actionresult receives the URL and displays the processing result with the view.
Right-click actionresult --> gotoview and modifyCode
Site.css (set the logo and page layout)
Note: The _ layout. cshtml file is equivalent to the parent page.
The content from our individual views will be displayed by the @ renderbody () command, and any common content that we want to appear outside of that can be added to the _ layout. cshtml markup.
(1) 3 images for site.css
(2) Add CSS reference and UL Li in _ layout. cshtml (you can delete the original _ layout. cshtml and create another _ layout. cshtml)
4. Create a model. The controller processes the model and uses the model to transmit values to the view.
(1) Add album and use detailview to display album details
> Add the album class under the model, including attributes such as ID and name.
> Add action details (INT albumid) to storecontroller)
> Add a view for the details action, declare the type of the received object in the view, and display the information of the model object in the view.
(2) Add genre and use browserview to display all genre
> Add genre class and main attributes
> Store C adds the Browse method and transmits all genre to the view using list
> View displays all genre names
6. html. actionlink (text, actionname, new {para = value}) Add dynamic links to the page