The latest ASP.net vnext is completely open source and can be run across multiple platforms, in the Windows environment I tried, almost no time to run up the sample, and in the Linux environment, it takes a lot longer, so special record the whole process, Hope to be helpful to other people who want to be a delicacy.
Operating Environment
Ubuntu Server 14.04
VirtualBox
Mono >= 3.4.1
* Since the mono version of the Ubuntu Library is older and less than meets the minimum requirements, the first step is to install the latest version of Mono.
Install Mono
1. First get mono code from github: Git clone git://github.com/mono/mono.git
* You will first need to perform the sudo apt-get install git command in Ubuntu without having a git program installed.
2. This step is a bit strange, the new version of the mono need to compile the support of the old version, if not installed mono, please perform the sudo apt-get install mono-complete command in Ubuntu first.
3. Enter the mono directory, compile the program:
CD mono./autogen.sh--prefix=/usr/localmake
* You may need to install other programs in advance, such as Autoconf,libtool,g++,make and so on.
4. Installation: Make install
5. Execute mozroots--import--sync command to avoid authentication issues.
6. Verify that the installed mono is the latest version through the Mono–version command.
Install Kre
A simple command is required:
Curl Https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | SH && source ~/.kre/kvm/kvm.sh && KVM Upgrade
The KVM Upgrade command automatically downloads the latest Kre package, extracts it into the. Kre/packages directory and adds the Bin folder path to your environment variable path.
* Because of the operation involved in decompression, the unzip program must be pre-installed: sudo apt-get install unzip
After the installation is complete, you can check that the installation is correct through the kpm–version command.
Hello World
After you have completed all of your preparations, you can try to run the first program. According to tradition, the first program should be "Hello world!"
1. First establish the HelloWorld folder: mkdir HelloWorld
2. After entering the folder: CD HelloWorld, then establish two files Program.cs and Project.json.
3. Edit these two files (recommended for VIM) and add the following code to Program.cs:
Using System;
public class program
{public
static void Main ()
{
Console.WriteLine ("Hello world!");
}
Instead, add the following configuration to the Project.json file:
{"
dependencies": {"System.Console":
"4.0.0.0"
},
"configurations": {
"net45": {},
"K10": {}
}
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/
4. Execute kpm restore-s https://www.myget.org/F/aspnetvnext/command.
* This command obtains the necessary dependencies from the specified NuGet warehouse according to the description in the configuration file.
5. Run the program: K Run
If the above steps are correct, you should be able to see "Hello world!" in the shell. The display.
Simple MVC
Then try a more complex program where the code can be obtained directly from the GitHub.
git clone git://github.com/aspnet/home.git
Getting HELLOMVC code is not directly available because the Web server it specifies does not exist in Linux, and we need to add a project to build the Web server.
Get the Nowin.vnext folder from the HTTPS://GITHUB.COM/ALXANDR/NOWIN.VNEXT/TREE/MASTER/SRC and place it in the same directory as the HELLOMVC.
Then modify the Hellomvc Project.json file:
{"
version": "0.1-alpha-*",
"dependencies": {
"MICROSOFT.ASPNET.MVC": "0.1-alpha-*",
"Nowin.vnext ': ' "
},
" commands ": {
" Web ":" Microsoft.AspNet.Hosting--server nowin.vnext "
},
" Configurations ": {" net45 ": {" dependencies ": {" system.runtime ":" "
,
" System.ComponentModel.DataAnnotations ":" "
}}
,
" K10 ": {}
}
}
After you run the kpm restore command to download a dependency, you can view the Web page in the browser by executing the K Web command.
* In fact, the above implementation will still have errors, need to put the Startup.cs file in the App.useerrorpage (); Usewelcomepage (); statement comment out. Guessing is a problem that has not been implemented in the Nowin.vnext server.
Client Access
Because the Ubuntu server used in this experiment does not have a desktop environment installed, it is not possible to view the results above in the virtual machine. However, since the virtual machine has become a service side, it is advisable to treat the host as a client bar.
In VirtualBox network settings, the connection mode is changed to a bridging network card so that the host can access the virtual machine via IP address.
The last example of the Web server port number is 8080, so in the host's browser on the "virtual machine IP Address: 8080" and a light hit enter the final results can be seen.