ASP NET Core Creates the base of a controller

    0

    3

    lucycodes42

    C# recipes

    This code defines a namespace named Name.Controllers and a controller class named NameController. The controller class has two public methods: Index() and Welcome(). Index() returns a view and Welcome() displays a message in the view.

    Shortcut: ac_controller

    namespace Name.Controllers
    {
    
      using Microsoft.AspNetCore.Mvc;
    
      public class NameController : Controller
      {
        public IActionResult Index()
        {
          return View();
        }
    
        public IActionResult Welcome()
        {
          ViewData["Message"] = "Your welcome message";
    
          return View();
        }
      }
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.