Ten minutes to get to know ASP. NET 5 (MVC6), asp. netmvc6
ASP. NET 5 is coming soon. I have been studying for two months. Today, I will write a simple ten-minute tutorial to my colleagues who have no contact with asp.net 5 to teach you how to get to know asp.net 5.
1. Install kvm
First, open cmd as an administrator and execute the following script:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.ps1'))"
After installation, install the latest version of KRE through kvm install latest-p.
2. Create the first application (Startup. cs and project. json)
In asp.net 5, the two most important files are Startup. cs and project. json.
Project. json file Description: https://github.com/aspnet/Home/wiki/Project.json-file
Startup. cs is the file found when the asp. net5 application starts, as shown in its name.
The following are the project. json and Startup. cs files.
A. Create an empty project. json file:
Run the following command in the current path:
The above command is the most basic package for installing and running the asp.net application. As shown in:
After the installation is complete, the project. json file is automatically updated:
Next, add the command node to the project. json file:
"commands": { "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000" }
The project. json file is as follows:
Now we have created the project. json file. Create the Startup. cs file.
Only the Hello World code is output.
3. Use k web to run the application.
The web command is defined in the project. json file. It will makeMicrosoft. AspNet. Server. WebListener listens to port 5000
4. Browse the page:
If you want to learn more about ASP. NET 5, refer to a project I'm learning, https://github.com/nicholaspei/OrchardNoCMS
There will be continuous updates to introduce the basic knowledge and features of ASP. NET 5.