NET Core 指令启动

ASP.NET Core 是新一代的 ASP.NET,早期称为 ASP.NET vNext,并且在推出初期命名为ASP.NET 5,但随着 .NET Core 的成熟,以及 ASP.NET 5的命名会使得外界将它视为 ASP.NET 的升级版,但它其实是新一代从头开始打造的 ASP.NET 核心功能,因此微软宣布将它改为与 .NET Core 同步的名称,即 ASP.NET Core。

ASP.NET Core 可运行于 Windows 平台以及非 Windows 平台,如 Mac OSX 以及 Ubuntu Linux 操作系统,是 Microsoft 第一个具有跨平台能力的 Web 开发框架。

微软在一开始开发时就将 ASP.NET Core 开源,因此它也是开源项目的一员,由 .NET 基金会 (.NET Foundation) 所管理。

正式版的.NET Core已于今天发布(2016年6月27日),具体可看微软 .NET Core 1.0 正式发布下载

ASP.NET Core 在 .NET Core 的基础上发展,目前规划的功能有:

  • ASP.NET Core MVC: ASP.NET Core MVC 提供了开发动态web站点的API,包括了WebPages 和 WebAPI ,最终可运行在IIS 或 自托管(self-hosted)的服务器中。

  • DependencyInjection: 包含了通用的依赖注入接口,用于在ASP.NET Core MVC中使用。

  • Entity Framework Core: 与之前版本的EntityFramework版本类似是一个轻量级的ORM框架,包括了Linq,POCO和Codefirst的支持。

  • ASP.NET Core Identity: 用于在ASP.NET Core web applications构建用户权限系统的框架,包括了membership、login等功能,同时也可以方便的扩展和自定义

一、安装the .NET Core SDK for Windows(Linux、MAC)

以Windows为例,(下载地址),
安装完成后可以用命令dotnet -v查看版本号。

C:Usersstephen>dotnet -v
Telemetry is: Enabled
.NET Command Line Tools (1.0.0-preview1-002702)
Usage: dotnet [common-options] [command] [arguments]

  

打开cmd 切换目录到项目目录

下载依赖包部署网站

dotnet restore

读取配置文件需要监听的ip

        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args">args</param>
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("hosting.json", true)
                .Build();

            var host = new WebHostBuilder()
                .UseKestrel()
                .UseConfiguration(config)
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .UseStartup<Startup>()
                .UseApplicationInsights()
                .Build();

            host.Run();
        }

  配置文件 

hosting.json
{
  "server.urls": "http://localhost:60000;http://localhost:60001"
}

  执行编译指令

dotnet build

  启动服务指令

dotnet run

  打开浏览器访问配置文件监听的地址

原文地址:https://www.cnblogs.com/liuxiaoji/p/6898119.html