- Learning ASP.NET Core 2.0
- Jason De Oliveira Michel Bruchet
- 372字
- 2021-07-02 22:04:16
Creating your first ASP.NET Core 2.0 application via the command line
In the previous section, you saw how to create your first ASP.NET Core 2.0 sample application with Visual Studio 2017, and this should be the preferred method for most common developers.
However, if you prefer using the command line or Visual Studio Code, which we are going to introduce a little later in the book, then using Visual Studio 2017 is not really an option. Luckily, .NET Core and ASP.NET Core 2.0 provide full support for the command line. This might even be your only option on other operating systems such as Linux or macOS. The same command-line instructions work on all the different operating systems, so, once you get used to them, you can work on any environment.
Let's see now how creating your first sample application using the Windows command line works:
- If the .NET Core 2.0 SDK is not yet installed, then download and install .NET Core Preview 2 from https://www.microsoft.com/net/core/preview.
Note that this step might no longer be needed at the time of reading this book, since it should have been released officially by then.
- Create a folder for your sample application, mkdir aspnetcoresample.
- Move into the created folder, cd aspnetcoresample.
- Create a new web application based on the empty ASP.NET Core 2.0 web application template, dotnet new web.
Previous versions of .NET Core required an additional -t parameter for choosing the template (dotnet new -t web). If you get an error when executing dotnet new web, it is a good indication that you need to install .NET Core 2.0.
Note that you can verify your .NET version by entering dotnet (with no parameters) if you are not sure about your environment, since it will display the current .NET Core version.
- Run the sample application by executing dotnet run:

- Open a browser and go to http://localhost:5000. If everything worked correctly, you should see a Hello World! page:

You have seen how to create your first sample application either by using Visual Studio 2017 or the command line. You will now see how to use Visual Studio Code and how it helps you when building an ASP.NET Core 2.0 application on Linux or macOS.
- 黑客攻防從入門到精通(實戰秘笈版)
- The Supervised Learning Workshop
- GraphQL學習指南
- C++ Builder 6.0下OpenGL編程技術
- Java Web開發之道
- ASP.NET Core 2 and Vue.js
- INSTANT MinGW Starter
- Python Geospatial Development(Second Edition)
- Apache Spark 2.x for Java Developers
- C#開發案例精粹
- SQL Server實用教程(SQL Server 2008版)
- Visual Basic語言程序設計基礎(第3版)
- Java核心編程
- Web 2.0策略指南
- Selenium WebDriver自動化測試完全指南