ASP. NET Core is much simpler than traditional ASP. NET, and it is much more flexible and can run independently across platforms.
On the Windows platform, as long as we choose the cross-platform. NET Core Development When installing Visual Studio, we can test the ASP. Without any configuration, and even IIS you can not enable (and of course you can enable), because using the Do The tnet command can be run directly. Of course, on MacOS and Linux are also run through the dotnet command.
In general, on the Windows platform, if your ASP. NET Core application runs smoothly, it is no problem to other platforms. However, it is better to test it across platforms.
Whether you want to learn Linux or want to test Core applications under Linux, the traditional approach might be to think about installing in a virtual machine. However, virtual machines are cumbersome and performance-intensive, as well as directly enabling the Linux subsystem under Windows 10, not only cost-saving, but also direct access to the Windows file directory for more straightforward operation.
The big guys might say, "I never used Linux. All right, as long as you use the CMD window on the line. This rotten text old week to install force, many people will think that will play Linux like Special cow, but the old weeks feel nothing great, not just open a command window practice typing. Linux has a so-called desktop version, but a little bit virtual. We do not need to play today's desktop, lose command on the line, Linux or command to operate more formal.
The above f is a lot of words, now ask you to drink a cup of pig milk, and then sit down, and the old Monday up to start playing it. Rest assured, very simple, you can learn.
Turn on the Linux subsystem under Windows 10
This is a very important step, and also the first step, you want to go to the control Panel, find "programs", and then close or enable Windows components. Then tick the "Windows Subsystem for Linux".
The system will then be configured, then restarted, and the reboot will be OK. This step will be, do not I teach, if this is not, then I have no way.
This is to open Bash, be sure to open this Ah, otherwise, when you start Linux will appear this prompt.
Install Ubuntu
There are two ways to install a Linux subsystem, although two methods, in essence, are downloaded in the App Store. One way is to run bash directly,
You can run bash in any directory, such as this:
Turn on the Power shell or CMD, and then enter bash to run, isn't it very TMD convenient.
When you start Bash, it will automatically download and install Linux.
The second way is to go to the store to download, the old week seriously recommend this method, because you can choose which to install. Currently, the store offers three releases.
For us to test or learn, we only install Ubuntu. As with the General UWP app installation, you can click Install.
Start entering Linux
After you install Ubuntu, you have two ways to run Linux. One is to start bash and the other is to run Ubuntu apps. Enter Ubuntu directly in the Cortana search box.
First run, it will prompt you, please wait a few minutes. Then you pour a cup of pig's milk and sit for a few minutes.
After you finish the pig milk, the estimated initialization is complete, and then you will see that it prompts you to enter the user name.
You can enter it casually, not necessarily with the name of your login Windows, it is only used in the subsystem, for example, the old week input Zhou. Then enter confirm, this common sense you want to know, all orders are enter confirm.
You will then be prompted to enter your password.
You have to pay attention to the process of losing the password, there is no display, so please remember which keys you pressed. This is for testing, subsystem, you do not need to set too complex password, just enter a mentally retarded password on the line, such as 123,ABC.
You will be prompted to confirm the password once again, you can lose again on the line. When you're done you'll be logged into the Ubuntu system, as long as you see something like this that shows you're successful.
Zhou is the username you just entered, followed by your current hostname, such as the old week's computer name is Zhou-surface, which is a Surface Pro 4. Then the colon, followed by the ~ indicates that you are currently in the working directory (current directory) is/home/< your username > below.
How to show the full path of the directory you are in now, the old week teaches you two tricks:
The first stroke, input: Echo $PWD. Note that Linux is heavily case-sensitive, so be careful when you enter commands.
After execution, the output is:
Zhou is a directory named after the current user, and if the user name you just entered is pig, then the/home/pig will be output.
PWD is an environment variable that represents the path of the current working directory, and after we switch directories, the PWD environment variable will change, not to believe you to try. Now switch to the/etc directory and then output it again.
See, the PWD becomes/etc.
The switch directory is the same as Windows, with the CD command, where the path is represented by "/" and the root directory.
As you may have seen, referring to an environment variable is preceded by a $ in the PWD, which does not ask you to pay in dollars, but rather the syntax of the variable reference, whether it is an environment variable or a variable that you temporarily define. For example, I temporarily define a variable called dog, and then when I refer to it, it is $dog.
Note dog= ' .... Do not appear in the middle of the space, do not write as Dog = ' xxxx ', this will prompt the error, because the content after the space is recognized as the command line parameters.
The function of the echo command is to output text, this command many platforms have, Windows can also be used, PHP is also used in this thing.
You see, unconsciously, entered a bunch of things.
Do you think that things on the screen too messy, look at the eyes grow hair, nothing, then you just click "Ctrl + L", the screen will immediately get out of things.
We just talked about it. Use $PWD environment variable to view the current working directory, and now the old week will tell you another way.
Enter the Pwd-p, and you're ready.
Note that the PWD is lowercase,-p is uppercase, and print means that the path to the current directory is printed.
How to Reset
This subsystem is fun, whether you're learning Linux or testing a. NET Core project, you can do anything you like, just don't get pregnant. If you're impulsive, get pregnant. Do not believe that the full street posted the kind of what painless + people, what scientific abortion, what no sequelae of drainage, all is deceptive.
You just need to open the "settings" of Win 10, find app management, and then go to advanced options.
See, there is a "reset" button on the page, you can reset it.
Note that resetting is only to the Linux subsystem, not your win 10, so rest assured that Windows files are unaffected, but any changes you make on Ubuntu, including the packages you install, will all be lost and will return to the state you just downloaded from the store.
Text Editor
It is still necessary to learn how to use a text editor, because you will write a configuration file when you install. NET Core and configure the server later. Linux on the use of a lot of text editor generally have VI, vim and so on. But that's a bit complicated, the old week recommended a simple and useful--nano.
The direct input of the Nano can be started.
The interface looks like Dongshi, no way, will be used, this simple, and completely enough for us to use.
You can enter something inside, just like this.
You apply keyboard operation all the way, the mouse does not need to move.
See the text at the bottom of the window, it is prompt you shortcut keys, you can press directly. How to press, the character ^ refers to the "CTRL" key, such as Get Help, you press Ctrl + G.
Now that you have entered the content, we want to save, follow the prompts, press the shortcut key "Ctrl + O", you will be prompted to enter the file name.
After entering the file name, enter it and save it.
Then press "Ctrl + X" to exit.
So, where are the files? Put it in your current working directory. For example, my current working directory is under/home/zhou, so the file is here.
You can enter this command to verify LS (the first character is the lowercase L, not the number 1), the LS command is the abbreviation for list, specifically lists the directories and files.
123.txt is the file I just saved.
Now, let's open it and see, Input: Nano-v 123.txt
This-v parameter, which is called read-only, is not modified if you want to modify the file, it warns you.
If you want to open it normally, you can remove the-v parameter.
If you don't want to open the file with the Nano editor and just want to see what's inside it, or want to output it directly to the command line window, you can use the Cat command.
After execution, the contents of the file are output directly.
To delete that file, use the RM command, type: RM 123.txt, enter.
=====================================================
OK, this is the place today, old week worry, talk more you can't digest. Let's talk about installing dotnet core and server packages, such as Nginx, in the Linux subsystem in the next old week.
ASP.: Configuring the Linux subsystem on Windows 10