2016-10-29 01:35:15 +08:00
---
2017-07-01 07:47:15 +08:00
title: Adding a controller
2018-01-29 23:21:31 +08:00
author: rick-anderson
2017-03-04 05:35:47 +08:00
description: How to add a controller to a simple ASP.NET Core MVC app
2016-10-29 01:35:15 +08:00
manager: wpickett
2018-01-29 23:21:31 +08:00
ms.author: riande
2017-03-04 05:35:47 +08:00
ms.date: 02/28/2017
2017-03-03 08:50:36 +08:00
ms.prod: asp.net-core
2018-01-29 23:21:31 +08:00
ms.technology: aspnet
ms.topic: get-started-article
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 )