005.Getting started with ASP.NET Core MVC and Visual Studio -- 【VS开发asp.net core mvc 入门】

Getting started with ASP.NET Core MVC and Visual Studio

VS开发asp.net core mvc 入门

2017-3-7 2 分钟阅读时长

本文内容

1.Install Visual Studio and .NET Core

安装 VS 与 .NET Core

2.Create a web app

创建一个 web 应用

By Rick Anderson

This tutorial will teach you the basics of building an ASP.NET Core MVC web app using Visual Studio 2017.

本教程将会教你如何使用VS2017创建一个基本的asp.net core mvc 应用程序

There are 3 versions of this tutorial:

除此之外,还有其它三个版本的教程(自己翻译~):

For the Visual Studio 2015 version of this tutorial, see the VS 2015 version of ASP.NET Core documentation in PDF format.

Install Visual Studio and .NET Core

安装 vs 与 .net core

Install Visual Studio Community 2017. Select the Community download. Skip this step if you have Visual Studio 2017 installed.

安装vs 2017 社区版。选择社区版下载。如果你已安装过可以跳过这个步骤。

Run the installer and select the following workloads:

运行这个安装包,选择下面的工作项:

  • ASP.NET and web development (under Web & Cloud)

需要勾选的环境一

  • .NET Core cross-platform development (under Other Toolsets)

需要勾选的环境二

Create a web app

创建一个 web 应用

From Visual Studio, select File > New > Project.

在vs中选择 File > New > Project 菜单,新建。

Complete the New Project dialog:

完成 新建项目 对话框:

  • In the left pane, tap .NET Core

在左边的窗格,点击 .net core

  • In the center pane, tap ASP.NET Core Web Application (.NET Core)

在中间的窗格,点击 ASP.NET Core Web Application (.NET Core)

  • Name the project "MvcMovie" (It‘s important to name the project "MvcMovie" so when you copy code, the namespace will

命名项目名称为 MvcMovie

match.)

  • Tap OK

点击 OK

Complete the New ASP.NET Core Web Application (.NET Core) - MvcMovie dialog:

完成 New ASP.NET Core Web Application (.NET Core) - MvcMovie 对话框:

  • In the version selector drop-down box tap ASP.NET Core 1.1

在版本选择下拉框中选择 ASP.NET Core 1.1 选项

  • Tap Web Application

点击 Web Application

  • Keep the default No Authentication

保持默认的 No Authentication 选择

  • Tap OK.

点击 OK

Visual Studio used a default template for the MVC project you just created. You have a working app right now by entering a project

VS使用一个默认的项目模板。在你键入项目名称与选择少量选项之后就有了一个可以正常工作的 web 应用。

name and selecting a few options. This is a simple starter project, and it‘s a good place to start,

这是一个简单的入门项目,同时是一个很好的起点,

Tap F5 to run the app in debug mode or Ctrl-F5 in non-debug mode.

点击 F5 在调试模式下启动这个程序,或者 ctrl+F5 非调试模式下运行该程序。

  • Visual Studio starts IIS Express and runs your app. Notice that the address bar shows localhost:port# and not something

VS启动 iis express 用于运行你的 app 程序。注意浏览器的地址栏显示的是ip+port,而不是常见的域名。

like example.com. That‘s because localhost is the standard hostname for your local computer. When Visual Studio creates

这是因为 localhost 是你本机的标准主机名。当VS创建一个新的web项目,

a web project, a random port is used for the web server. In the image above, the port number is 5000. When you run the app,

一个随机的端口会被 web server 选择使用。在上图中,端口是5000. 在你自己运行这个app的时候,

you‘ll see a different port number.

你可能会看到一个不同的端口。

  • Launching the app with Ctrl+F5 (non-debug mode) allows you to make code changes, save the file, refresh the browser, and

在非调试模式下启动应用,允许你做一些代码变更,保存文件,刷新浏览器,并且

see the code changes. Many developers prefer to use non-debug mode to quickly launch the app and view changes.

查看变更。许多开发者更喜欢使用非调试模式快速启动应用并查看变更。

  • You can launch the app in debug or non-debug mode from the Debug menu item:

你可以在 Debug 菜单已调试或非调试模式启动你的app:

  • You can debug the app by tapping the IIS Express button

你可以通过点击 IIS Express 按钮启动调试程序

The default template gives you working Home, About and Contact links. The browser image above doesn‘t show these links.

默认的模板提供了 Home, About and Contact  三个链接与页面。上图中浏览器没有显示这些链接。

Depending on the size of your browser, you might need to click the navigation icon to show them.

因为依赖于你的浏览器宽度尺寸,你可能需要点击导航图标来显示他们。

If you were running in debug mode, tap Shift-F5 to stop debugging.

如果你在调试模式下运行,点击 Shift-F5 可以停止调试。

In the next part of this tutorial, we‘ll learn about MVC and start writing some code.

在接下来的教程中,我们将会开始学习 mvc 和如何开始写一些 代码 。

                                         蒙

                                    2017-07-12 11:05 周三

时间: 2024-08-08 04:02:29

005.Getting started with ASP.NET Core MVC and Visual Studio -- 【VS开发asp.net core mvc 入门】的相关文章

Visual Studio 2015 开发 ASP.NET 5

在以往微软发布或更新 Visual Studio 版本时,我们开发 ASP.NET 应用程序,带给我们的变化其实并不是很大,或者说你根本就感受不到变化,你感受到的只是下载安装了几个 G 的 Update 更新包,但这次微软发布更新的 ASP.NET,无疑是巨大的,首先我们来看下 ASP.NET 5 的新功能介绍: Web Forms.MVC 和 Web API 统一编程模型. 无编译开发体验(no-compile),修改代码文件,无需编译,只需要浏览器刷新即可. 无缝云开发支持(Cloud-re

Visual Studio 2015 开发 ASP.NET 5 有何变化?(转)

出处:http://www.cnblogs.com/xishuai/p/visual-studio-2015-preview-asp-net-5-change.html 本篇博文目录: ASP.NET 5 模版 ASP.NET 5 目录结构 前端管理工具 无编译开发 Microsoft Git Provider 智能感知和错误信息 Smart Unit Testing 等待发现... Visual Studio 2015 Preview 版本部分说明: ASP.NET 5 Preview run

Mac上使用Visual Studio Code开发/调试.NET Core代码

Mac上使用Visual Studio Code开发/调试.NET Core代码 .Net Core 1.0终于发布了,Core的一大卖点就是跨平台.这个跨平台不只是跨平台运行,而且可以跨平台开发.今天抽空研究了下在Mac下如何使用VS Code来开发.NET Core程序,并且调试代码. 1.安装.NET Core 在mac上打开终端: ~$ brew update ~$ brew install openssl ~$ brew link --force openssl 如果不能使用brew命

使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(一)-- 起步

本文记录了在Windows环境下安装Visual Studio Code开发工具..Net Core 1.0 SDK和开发一个简单的Web-Demo网站的全过程. 一.安装Visual Studio Code 安装文件下载地址:VS Code,当前最新版本是1.3. 推荐安装最新版,因为附带Debug插件,支持在vs code上进行断点调试. 二.安装.Net Core 1.0 SDK 安装文件下载地址:.Net Core SDK 三.创建一个.Net Core应用程序 1. 打开cmd窗口,创

使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(三)-- Logger

本篇是在上一篇的基础上添加日志功能,并记录NLog在Asp.Net Core里的使用方法. 第一部分:默认Logger支持 一.project.json添加日志包引用,并在cmd窗口使用 dotnet restore 命令还原包文件. 1 { 2 "version": "1.0.0-*", 3 "buildOptions": { 4 "debugType": "portable", 5 "emit

使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(十)-- 发布(Windows)

本篇将在这个系列演示的例子上继续记录Asp.Net Core在Windows上发布的过程. Asp.Net Core在Windows上可以采用两种运行方式.一种是自托管运行,另一种是发布到IIS托管运行. 第一部分.自托管 一.依赖.Net Core环境 修改 project.json 文件内容,增加发布时需要包含文件的配置内容 1 { 2 "version": "1.0.0-*", 3 "testRunner": "xunit&quo

使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(五)-- Filter

在上一篇里,介绍了中间件的相关内容和使用方法.本篇将介绍Asp.Net Core MVC框架的过滤器的相关内容和使用方法,并简单说明一下与中间件的区别. 第一部分.MVC框架内置过滤器 下图展示了Asp.Net Core MVC框架默认实现的过滤器的执行顺序: Authorization Filters:身份验证过滤器,处在整个过滤器通道的最顶层.对应的类型为: AuthorizeAttribute.cs Resource Filters:资源过滤器.因为所有的请求和响应都将经过这个过滤器,所以

使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(三)-- Lo

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 本篇是在上一篇的基础上添加日志功能,并记录NLog在Asp.Net Core里的使用方法. 第一部分:默认Logger支持 一.project.json添加日志包引用,并在cmd窗口使用 dotnet restore 命令还原包文件. 1 {

使用Visual Studio 2015 开发ASP.NET MVC 5 项目部署到Mono/Jexus

最新的Mono 4.4已经支持运行asp.net mvc5项目,有的同学听了这句话就兴高采烈的拿起Visual Studio 2015创建了一个mvc 5的项目,然后部署到Mono上,浏览下发现一堆错误出现,心中一万只草泥马奔腾而来,这也叫支持吗,这个问题是Visual Studio造成的,不相信的话可以使用Xamarin.Studio创建的asp.net项目,部署过程非常顺利,没有遇到什么问题:本文就是为你解开这个结,如何Visual Studio 2015搞定ASP.NET MVC 5项目的

在Mac上使用Visual Studio Code开发/调试.NET Core代码

.Net Core 1.0终于发布了,Core的一大卖点就是跨平台.这个跨平台不只是跨平台运行,而且可以跨平台开发.今天抽空研究了下在Mac下如何使用VS Code来开发.NET Core程序,并且调试代码. 1.安装.NET Core 在mac上打开终端: ~$ brew update ~$ brew install openssl ~$ brew link --force openssl 如果不能使用brew命令,先安装homebrew,玩转Mac必备. 下载.NET Core SDK:ht