ADDController.md - brainchildservices/curriculum GitHub Wiki
SLIDE-1
- ASP.NET MVC Controller:
Controller interacts among Models and Views.
SLIDE-2
-
Recheck on ASP.NET MVC Controller
SLIDE-3
- Now let's add a controller to your project.
SLIDE-3(DOWNWARDS)
- Use the following procedure to add a Controller to your project:
SLIDE-4
How to create new Controller Using VS Code.
Go to the Explorer window in VS Code. Right Click the Controllers folder and point to New File, followed by clicking the New File.
SLIDE-4(DOWNWARDS)
Now, you can type in controller name as HelloWorldController.cs
and press the Enter button.
SLIDE-4(DOWNWARDS)
Copy and paste the below code into HelloWorldController.cs
using Microsoft.AspNetCore.Mvc;
namespace SampleMVCApps.Controllers
{
public class HelloWorldController:Controller
{
public IActionResult Index()
{
ViewData["Message"]="Hello, This is my view";
return View();
}
public IActionResult Welcome()
{
ViewData["Message"]="Hello, Welcome to HelloWorld Application";
return View();
}
}
}
Ref:- https://www.c-sharpcorner.com/article/getting-started-with-asp-net-core-mvc-apps-using-vs-code/