2017-06-17 05:40:44 +08:00
|
|
|
---
|
2018-03-22 08:18:35 +08:00
|
|
|
title: Add a controller to an ASP.NET Core MVC app with Visual Studio for Mac
|
2018-01-29 23:21:31 +08:00
|
|
|
author: rick-anderson
|
2017-06-17 05:40:44 +08:00
|
|
|
description: How to add a controller to a basic ASP.NET Core MVC app using Visual Studio of Mac
|
2018-01-29 23:21:31 +08:00
|
|
|
ms.author: riande
|
2017-06-17 05:40:44 +08:00
|
|
|
ms.date: 06/28/2017
|
|
|
|
uid: tutorials/first-mvc-app-mac/adding-controller
|
|
|
|
---
|
2018-03-22 08:18:35 +08:00
|
|
|
# Add a controller to an ASP.NET Core MVC app with Visual Studio for Mac
|
2017-06-17 05:40:44 +08:00
|
|
|
|
|
|
|
By [Rick Anderson](https://twitter.com/RickAndMSFT)
|
|
|
|
|
2018-04-05 07:51:35 +08:00
|
|
|
[!INCLUDE [adding-controller](../../includes/mvc-intro/adding-controller1.md)]
|
2017-06-17 05:40:44 +08:00
|
|
|
|
|
|
|
## Add a controller
|
|
|
|
|
|
|
|
In **Solution Explorer**, right-click **Controllers > Add > New File**.
|
|
|
|
|
|
|
|
![Contextual menu](adding-controller/_static/add_controller.png)
|
|
|
|
|
|
|
|
Select **ASP.NET Core** and **MVC Controller Class**.
|
|
|
|
|
|
|
|
Name the controller **HelloWorldController**.
|
|
|
|
|
|
|
|
![Add MVC controller and name it](adding-controller/_static/ac.png)
|
|
|
|
|
2018-04-05 07:51:35 +08:00
|
|
|
[!INCLUDE [adding-controller2](../../includes/mvc-intro/adding-controller2.md)]
|
2017-06-17 05:40:44 +08:00
|
|
|
|
2018-04-05 07:51:35 +08:00
|
|
|
> [!div class="step-by-step"]
|
|
|
|
> [Previous](../first-mvc-app/start-mvc.md)
|
|
|
|
> [Next](adding-view.md)
|