2017-06-17 05:40:44 +08:00
|
|
|
---
|
|
|
|
title: Adding a controller to an ASP.NET Core MVC app
|
|
|
|
author: rick-anderson
|
|
|
|
description: How to add a controller to a basic ASP.NET Core MVC app using Visual Studio of Mac
|
2017-09-21 15:03:27 +08:00
|
|
|
keywords: ASP.NET Core,MVC,controller
|
2017-06-17 05:40:44 +08:00
|
|
|
ms.author: riande
|
|
|
|
manager: wpickett
|
|
|
|
ms.date: 06/28/2017
|
|
|
|
ms.topic: article
|
|
|
|
ms.assetid: e04b6666-d0de-4d99-b78f-d6a0c4634a87
|
|
|
|
ms.technology: aspnet
|
|
|
|
ms.prod: asp.net-core
|
|
|
|
uid: tutorials/first-mvc-app-mac/adding-controller
|
|
|
|
---
|
2017-06-23 22:08:01 +08:00
|
|
|
# Adding 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)
|
|
|
|
|
|
|
|
[!INCLUDE[adding-controller](../../includes/mvc-intro/adding-controller1.md)]
|
|
|
|
|
|
|
|
## 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)
|
|
|
|
|
|
|
|
[!INCLUDE[adding-controller2](../../includes/mvc-intro/adding-controller2.md)]
|
|
|
|
|
|
|
|
>[!div class="step-by-step"]
|
|
|
|
[Previous](../first-mvc-app/start-mvc.md)
|
|
|
|
[Next](adding-view.md)
|