ASP.NET Core 中文文档 第一章 入门
2017-12-01 14:24
465 查看
本文已更新,最后更新于2017年4月21日
原文:Geting Started with ASP.NET Core
译文:ASP.NET Core 入门
翻译:娄宇(Lyrics)、刘怡(AlexLEWIS)(修订)
联系我们:
QQ Group: 436035237 (dotNet Core Studying Group)
GitHub Repo: https://github.com/dotnetcore/aspnetcore-doc-cn/
以下为老翻译存档
原文:Getting Started
翻译:娄宇(Lyrics)
校对:刘怡(AlexLEWIS)
1、安装 .NET Core
2、创建一个新的 .NET Core 项目:
3、编辑 project.json 文件,添加 Kestrel Http Server 包引用:
4、还原包:
5、添加一个 Startup.cs 文件并定义请求处理逻辑:
6、编辑 Program.cs 中的代码来设置和启动 Web 宿主:
7、运行应用程序(
8、浏览
DEMO 代码
用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API
原理
返回目录
原文:Geting Started with ASP.NET Core
译文:ASP.NET Core 入门
翻译:娄宇(Lyrics)、刘怡(AlexLEWIS)(修订)
联系我们:
QQ Group: 436035237 (dotNet Core Studying Group)
GitHub Repo: https://github.com/dotnetcore/aspnetcore-doc-cn/
以下为老翻译存档
原文:Getting Started
翻译:娄宇(Lyrics)
校对:刘怡(AlexLEWIS)
1、安装 .NET Core
2、创建一个新的 .NET Core 项目:
mkdir aspnetcoreapp cd aspnetcoreapp dotnet new
3、编辑 project.json 文件,添加 Kestrel Http Server 包引用:
{ "version": "1.0.0-*", "buildOptions": { "emitEntryPoint": true }, "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-3002702" }, "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final" }, "frameworks": { "netcoreapp1.0": { "imports": "dnxcore50" } } }
4、还原包:
dotnet restore
5、添加一个 Startup.cs 文件并定义请求处理逻辑:
using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; namespace aspnetcoreapp { public class Startup { public void Configure(IApplicationBuilder app) { app.Run(context => { return context.Response.WriteAsync("Hello from ASP.NET Core!"); }); } } }
6、编辑 Program.cs 中的代码来设置和启动 Web 宿主:
using System; using Microsoft.AspNetCore.Hosting; namespace aspnetcoreapp { public class Program { public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseStartup<Startup>() .Build(); host.Run(); } } }
7、运行应用程序(
dotnet run命令在应用程序过期(配置或代码发生变更)时重新生成它):
dotnet run
8、浏览
http://localhost:5000:
DEMO 代码
下一步
用 Visual Studio 创建 ASP.NET Core MVC 应用程序用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API
原理
返回目录
相关文章推荐
- ASP.NET Core 中文文档 第一章 入门
- ASP.NET Core 中文文档 第一章 入门
- IdentityServer4 中文文档 -14- (快速入门)使用 ASP.NET Core Identity
- ASP.NET Core 中文文档 第二章 指南(4.1)ASP.NET Core MVC 与 Visual Studio 入门
- ASP.NET Core 中文文档 第四章 MVC(4.6)Areas(区域)
- ASP.NET Core 中文文档 第四章 MVC(2.2)模型验证
- ASP.NET Core 中文文档 第二章 指南(2)用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API
- ASP.NET Core 中文文档 第二章 指南(4.2)添加 Controller
- ASP.NET Core 中文文档 第二章 指南(2)用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API
- [转]ASP.NET Core 中文文档 第四章 MVC(4.3)过滤器
- ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core
- ASP.NET Core 中文文档 第三章 原理(4)路由
- ASP.NET Core 中文文档 第二章 指南(4.7)添加搜索
- ASP.NET Core 中文文档 第三章 原理(5)错误处理
- ASP.NET Core 中文文档 第三章 原理(17)为你的服务器选择合适版本的.NET框架
- ASP.NET Core 中文文档 第二章 指南(1)用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
- ASP.NET Core 中文文档 第四章 MVC(4.5)测试控制器逻辑
- ASP.NET Core 中文文档 第三章 原理(8)日志
- ASP.NET Core 中文文档 第四章 MVC(4.3)过滤器
- ASP.NET Core 中文文档 第三章 原理(1)应用程序启动