2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: Adding a controller
2017-03-04 05:35:47 +08:00
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
2017-03-04 05:35:47 +08:00
ms.date: 02/28/2017
2017-06-01 05:55:29 +08:00
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
2017-03-03 08:50:36 +08:00
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
2017-06-17 05:40:44 +08:00
By [Rick Anderson ](https://twitter.com/RickAndMSFT )
2016-10-29 01:35:15 +08:00
2017-06-17 05:40:44 +08:00
[!INCLUDE[adding-controller1 ](../../includes/mvc-intro/adding-controller1.md )]
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
* In **Solution Explorer** , right-click **Controllers > Add > New Item**
2016-10-29 01:35:15 +08:00
2016-12-23 02:03:29 +08:00
![Contextual menu ](adding-controller/_static/add_controller.png )
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +08:00
* Select **MVC Controller Class**
2016-10-29 01:35:15 +08:00
* In the **Add New Item** dialog, enter **HelloWorldController** .
2017-03-04 05:35:47 +08:00
![Add MVC controller and name it ](adding-controller/_static/ac.png )
2017-06-17 05:40:44 +08:00
[!INCLUDE[adding-controller2 ](../../includes/mvc-intro/adding-controller2.md )]
2016-10-29 01:35:15 +08:00
2017-03-04 05:35:47 +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 )