2017-03-30 05:15:18 +08:00
---
2018-03-20 07:40:34 +08:00
title: Add a controller to an ASP.NET Core app
2018-01-29 23:21:31 +08:00
author: rick-anderson
2018-03-20 07:40:34 +08:00
description: Learn how to add a controller to a simple ASP.NET Core MVC app.
2017-03-30 05:15:18 +08:00
manager: wpickett
2018-01-29 23:21:31 +08:00
ms.author: riande
2017-03-30 05:15:18 +08:00
ms.date: 02/28/2017
ms.prod: asp.net-core
2018-01-29 23:21:31 +08:00
ms.technology: aspnet
ms.topic: get-started-article
2017-03-30 05:15:18 +08:00
uid: tutorials/first-mvc-app-xplat/adding-controller
---
2018-03-20 07:40:34 +08:00
# Add a controller to an ASP.NET Core app
2017-03-30 05:15:18 +08:00
2017-06-17 05:40:44 +08:00
By [Rick Anderson ](https://twitter.com/RickAndMSFT )
2017-03-30 05:15:18 +08:00
2018-04-05 07:51:35 +08:00
[!INCLUDE [adding-controller ](../../includes/mvc-intro/adding-controller1.md )]
2017-03-30 05:15:18 +08:00
2018-01-03 04:34:00 +08:00
* In **VS Code** , select the **EXPLORER** icon and then control-click (right-click) **Controllers > New File** and name the new file HelloWorldController.cs.
2017-03-30 05:15:18 +08:00
2018-04-05 07:51:35 +08:00
![Contextual menu ](adding-controller/_static/new_file.png )
2017-03-30 05:15:18 +08:00
2018-04-05 07:51:35 +08:00
[!INCLUDE [adding-controller2 ](../../includes/mvc-intro/adding-controller2.md )]
2017-03-30 05:15:18 +08:00
2018-04-05 07:51:35 +08:00
> [!div class="step-by-step"]
> [Previous - Add a controller](start-mvc.md)
> [Next - Add a view](adding-view.md)