Downloaded and installed visual Studio Ultimate RC and MS SQL Server 2014. With the latest version, you can learn and learn about the newest technologies.
Go to the official Microsoft website and learn about MVC tutorials:
Http://www.asp.net/mvc
To listen to the recommended MVC video on Microsoft's website, although it is taught in English, watch the operation ...
http://pluralsight.com/training/player?author=scott-allen&name=mvc4-building-m1-intro&mode=live& Clip=0&course=mvc4-building
Buy an MVC book, "ASP. NET MVC 4 Web Programming":
Finally, create your own first MVC application, select the Visual C # language and. NET Framework4.5:
The project has been created and you can see that some files have been created for us in the solution, as well as some references
Where the folder controllers is the place where the controller is placed (it can be summed up to this folder as the previous. cs file, which can be understood, but that's not the case)
Folder models is where the data model resides
Folder views are places where pages are displayed (that is, files with the. aspx suffix)
We look back at the folder path, and we have learned the path in the ASP. NET is very different, in fact, the paths here are rewritten, specifically where to rewrite, we look at "Global.asax", Find "Global.asax.cs":
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using SYSTEM.WEB.MVC;
Using System.Web.Routing;
Namespace Mvcdemo
{
Note: For instructions on enabling IIS6 or IIS7 Classic mode,
Please visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication:System.Web.HttpApplication
{
public static void RegisterRoutes (RouteCollection routes)
{
Routes. Ignoreroute ("{resource}.axd/{*pathinfo}");
Routes. MapRoute (
"Default",//route name
' {controller}/{action}/{id} ',//URL with parameter
New {controller = "Home", action = "Index", id = urlparameter.optional}//parameter default value
);
}
protected void Application_Start ()
{
Arearegistration.registerallareas ();
RegisterRoutes (routetable.routes);
}
}
}
The core code is:
public static void RegisterRoutes (RouteCollection routes)
{
Routes. Ignoreroute ("{resource}.axd/{*pathinfo}");
Routes. MapRoute (
"Default",//route name
' {controller}/{action}/{id} ',//URL with parameter
New {controller = "Home", action = "Index", id = urlparameter.optional}//parameter default value
);
}
This static method is used to rewrite the path, you can see the routes. MapRoute (
"Default",//route name
' {controller}/{action}/{id} ',//URL with parameter
, this is the format of the URL that will be rewritten in the future
Explain an Index method under the Home controller in our Url:http://localhost:2906/home/index, not the file path we normally see.
All right, just write it down here and keep trying.
An Introduction to MVC Learning Notes (i) First MVC application (Basics)