The. NET Core Learning Path

Source: Internet
Author: User
Tags dot net dotnet new set hosting what is asp

1.NET Core Environment Setup

Install. NET Core:

. NET core includes the. NET core Runtime and the. NET Core SDK:

    1. NET core = Application Run dependent. NET Core runtime
    2. NET core SDK = using. NET core Development app. NET Core Runtime and SDK+CLI (software development kit/command line Interface) tools

Please go to dotnet official website dot.net (dot net), very good to remember, this site is also your introductory. NET core portal, remember that this is a must go to the site. The specific address of the. NET core Download: https:// Www.microsoft.com/net/download#core, here are a few things to note:

A. Although the. NET core runtime and the base library are already 1.0 RTM, the development toolchain (. NET core cli,visual Studio and Visual Studio Code) is a preview version, see https://blogs.ms dn.microsoft.com/dotnet/2016/05/06/net-core-rc2-improvements-schedule-and-roadmap/

B. To deploy an app on Windows servers, you can install ASP. NET Core Module for IIS separately without installing the. can be dotnetcore.1.0.0-windowshosting.exe by command line opt_install_redist=0

The minimum requirement for the C.MAC system is MacOS 10.11 (El Capitan)

B.h NET Core is supported on the Red Hat series servers to RHEL 7 server, including CentOS 7 above, specifically see https://access.redhat.com/documentation/en/dot-net-core/

E.. NET Core Support on Ubuntu requires Ubuntu 14.04 lts and Ubuntu 16.04 LTS

F. If you previously installed the BETA,RC1,RC2 version of. NET core, you need to uninstall them before installing, see the article in stack overflow.

The specific installation method for. NET core can be see the article. NET Core series: 1, the environment is built.

and the CLI command of the Core, please refer to Zhang's blog: Getting Started with. NET Core Environment Build and command line CLI

The above paragraph is also excerpted from Zhang Big blog, summed up better than I am too much.

Basic Introduction to 2.NET core 2.1 What is ASP . NET Core

ASP. NET Core is a new open-source, cross-platform framework that can be used to build modern, web-based cloud applications, such as the Internet of Things, IoT applications, and mobile backend. The ASP. NET core can be run on either the, or the complete. NET Framework, and its architecture provides an optimal development framework for applications that are published to the cloud or run on-premises, consisting of a small, modular component that preserves your flexibility in structuring the solution. You can develop and run your ASP. NET Core applications across platforms on devices such as Windows, Macs, and Linux. The source code for ASP. NET Core is already hosted on GitHub.

2.2 ASP. NET Core Improvements

1) Build Web UI and Web APIs in a unified scenario

2) Integrated modern client development framework and workflow

3) A cloud-ready environment-based configuration system

4) built-in dependency injection

5) New, lightweight, modular HTTP request pipeline

6) The ability to host an application in IIS or in its own hosting process.

7) Support for concurrent application versioning based on. NET Core.

8) fully distributed in NuGet package mode

9) A new set of tools to simplify modern web development

10) Develop and run ASP on devices such as Windows, Mac, and Linux. NET application

11) Open source and community focus

2.3 ASP. NET Core Project Interpretation

Example: an ASP. NET core application is actually a simple console application, but it creates a WEB server in the main method.

usingSystem.IO;usingMicrosoft.AspNetCore.Hosting;namespaceprogrammersliveshow{/// <summary>    ///System Initialization Information/// </summary>    ///To modify a record:     Public classProgram { Public Static voidMain (string[] args) {            varHost =NewWebhostbuilder (). Usekestrel (). Usecontentroot (Directory.GetCurrentDirectory ()). Useiisintegration (). Usestartup<Startup>()                .            Build (); Host.        Run (); }    }}

Main uses a webhostbuilder that follows the builder pattern to create the Web application host. The generator has a method that defines the Web server (Usekestrel) and specifies the startup class (Usestartup<startup> ()). The above example uses a Kestrel Web server, but you can specify a different type of Web server. More Usestartup-related information will be shown in the next section. Webhostbuilder provides a number of options, including specifying the host for IIS and IIS Express server useiisintegration, specifying usecontentroot for the content root directory, and so on. The build and run methods are used to build an instance of Iwebhost, which will be used to mount the app and start listening for incoming HTTP requests.

Startup class:

The startup method on Webhostbuilder is used to specify the startup class for your application.

This class is where the request processing pipeline is defined and the service that the application needs is configured. The startup class must be public and must contain the configureservices (iservicecollection services) and configure (Iapplicationbuilder app) methods.

A) configureservices defines the services used in the application (for example: ASP. NET MVC Core Framework, Entity framework core,identity, etc.)

b) Configure define the middleware in the request processing pipeline

the execution order of the Startup 构造 -> configureServices->configure class:.

For details, please refer to: Startup and middleware (middleware), the summary is very good.

Project.json

{  "Dependencies": {    "Microsoft.NETCore.App": {      "version":"1.0.0",      "type":"Platform"    },    "Microsoft.AspNetCore.Diagnostics":"1.0.0",    "Microsoft.AspNetCore.Server.IISIntegration":"1.0.0",    "Microsoft.AspNetCore.Server.Kestrel":"1.0.0",    "Microsoft.Extensions.Logging.Console":"1.0.0"  },  "Tools": {    "Microsoft.AspNetCore.Server.IISIntegration.Tools":"1.0.0-preview2-final"  },  "Frameworks": {    "netcoreapp1.0": {      "Dependencies": {        "Pls.service": {          "Target":"Project"        }      },      "Imports": [        "dotnet5.6",        "Portable-net45+win8"      ]    }  },  "buildoptions": {    "Emitentrypoint":true,    "Preservecompilationcontext":true  },  "runtimeoptions": {    "configproperties": {      "System.GC.Server":true    }  },  "publishoptions": {    "include": [      "wwwroot",      " views",      "Appsettings.json",      "Web. config",      "areas",      "Nlog.config"    ],    "Exclude": ["bin" ]  }}

The specific explanation please see Project.json Citation (Chinese version of suitable for English bad people to look over). I'll pick a few of the explanations explained above:

  1. Dependencies: A dependency that defines an object for a project's package dependencies, each of which is a package name, and each value contains version information. For more information, see Dependency Resolution article on the NuGet documentation site, type is object.
  2. tools: Defines an object that is used as a package dependency for the current project tool rather than as a reference. The package defined here can be used for scripts running during the build process, but the code for the project itself is not accessible, and the type is object.
  3. frameworks:框架,指定此项目支持的框架,如 .NET Framework 或通用 Windows 平台 (UWP)。 必须是有效的目标框架名字对象 (TFM)。 每个值都是一个对象,可以包含特定于此框架的信息以及以下各部分中的属性,类型是Object
  4. Target: Restrict dependencies to match only project orpackage,累屎是String
  5. Buildoptions: An object whose properties control the compilation of various aspects. Valid properties are listed below. You can also specify the target frame as described in the frame section, which is type object.
  6. runtimeoptions: Specifies the parameters that are supplied to the runtime during initialization, and the type is Object.
  7. Configproperties: Contains configuration properties that are used to configure the runtime and framework, and the type is object.
  8. System.GC.Server: To enable server garbage collection true ; false The default value is false .
  9. Emitentrypoint: To create an executable file true ; false The default value is false .
  10. Preservecompilationcontext: To preserve reference assemblies and other context data to implement run-time compilation true ; false The default value is false .
  11. Publishoptions: An object that contains the properties of the compiled configuration, and is of type objects.
  12. Include: Contains file and folder, type is String or string[with wildcard mode].
  13. Exclud e: Specifies the file to exclude from the build, which is of type String or string[with wildcard mode]. 

Beginner's Mind Mall: Beginner's mind Mall mvc/. NET group:159227188

The. NET Core Learning Path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.