AspNetCore.Docs/aspnetcore/tutorials/first-mvc-app/adding-controller.md

38 lines
1.2 KiB
Markdown
Raw Normal View History

2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: Adding a controller
author: rick-anderson
description: How to add a controller to a simple ASP.NET Core MVC app
keywords: ASP.NET Core, MVC
2016-10-29 01:35:15 +08:00
ms.author: riande
manager: wpickett
ms.date: 02/28/2017
ms.topic: get-started-article
2016-10-29 01:35:15 +08:00
ms.assetid: e04b6665-d0de-4d99-b78f-d6a0c4634a87
2016-11-17 08:24:57 +08:00
ms.technology: aspnet
ms.prod: asp.net-core
2016-10-29 01:35:15 +08:00
uid: tutorials/first-mvc-app/adding-controller
---
2017-06-27 05:53:19 +08:00
# Adding a controller to a ASP.NET Core MVC app with Visual Studio
2016-10-29 01:35:15 +08:00
By [Rick Anderson](https://twitter.com/RickAndMSFT)
2016-10-29 01:35:15 +08:00
[!INCLUDE[adding-controller1](../../includes/mvc-intro/adding-controller1.md)]
2016-10-29 01:35:15 +08:00
* In **Solution Explorer**, right-click **Controllers > Add > New Item**
2016-10-29 01:35:15 +08:00
![Contextual menu](adding-controller/_static/add_controller.png)
2016-10-29 01:35:15 +08:00
* Select **MVC Controller Class**
2016-10-29 01:35:15 +08:00
* In the **Add New Item** dialog, enter **HelloWorldController**.
![Add MVC controller and name it](adding-controller/_static/ac.png)
[!INCLUDE[adding-controller2](../../includes/mvc-intro/adding-controller2.md)]
2016-10-29 01:35:15 +08:00
In Visual Studio, in non-debug mode (Ctrl+F5), you don't need to build the app after changing code. Just save the file, refresh your browser and you can see the changes.
2016-10-29 01:35:15 +08:00
2016-11-10 13:17:21 +08:00
>[!div class="step-by-step"]
[Previous](start-mvc.md)
[Next](adding-view.md)