Laugh at yourself ... Everything has to start with the official entry.
Because you can't find an example of getting started with MVC for new newbies, go back and do Microsoft's "ASP." MVC4 Getting Started guide.
Only to put oneself in the sun exposure, only to know that they have many dishes!
Beginner's experience, in case of being seen, please correct me
I. Access to the action method
Namespace Mvcmovie.controllers
{
public class Helloworldcontroller:controller
{
//
Get:/helloworld/ From here can be seen is a get mode of Access
public string Index ()
{
Return "This is my <b>default</b> action Methord";
}
//
Get:/helloworld/welcom From here can be seen is a get mode of Access
public string Welcome ()
{
Return "This is the Welcome action Methord";
}
}
}
There are two action (methods) in a hellowordcontroller, which can be accessed by/control/action to see the character content after return.
Picture 1
Access address is/helloworld/here only the controller's name is not index this method, because the default access to the index method in the route
Actually, it's/helloword/index.
Picture 2
For access to the default method that is not mapped in the route, the access format is/controllername/actionname
So access the Welcome method, access address is/helloworld/welcome
Picture 3
You see this picture? The action method also shows the data, more than 1, Figure 2, and the table in Picture 3 illustrates the problem.
Not necessarily in the view (it's inconvenient)
This shows that MVC is the code splitting.
How do you divide it? Microsoft's view is as follows:
MVC represents: model - view - controller . MVC is a well-architected and easy-to-test and maintainable development model.
Applications based on the MVC pattern include:
· Models: Data class that represents the data for the application and uses validation logic to enforce the business rules.
· Views: The template file used by the application to dynamically generate HTML.
· Controllers: Process the browser request, obtain the data model, and then specify the view template to respond to the browser request.
The code for Picture 3 is as follows:
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using SYSTEM.WEB.MVC;
Namespace Mvcmovie.controllers
{
public class Helloworldcontroller:controller
{
//
GET:/helloworld/
public string Index ()
{
Return "This is my <table border=1><tr><td><b>default</b></td></tr></ table> action Methord ";
}
//
GET:/helloworld/welcom
public string Welcome ()
{
Return "This is the Welcome action Methord";
}
}
}
--asp.net MVC4 Getting Started Guide (2): Adding a Controller