Complete ASP.NET 6.0 Course Build real-world applications

1. ASP .Net Basics

1.3. Intro to ASP.NET 6.0

1.4. MVC vs Razor vs Blazor

2. ASP.Net MVC

2.3.MVC-Model View Controller

2.4.Creating an MVC Project

2.5.Adding a Controller.

首页
一个controller对应一个view下的文件夹, 我们先返回字符串而不是view()
program.cs下设置启动页

using System.Web.Mvc;

namespace FirstMVC.Controllers
{
    public class HelloWorldController : Controller
    {
        // GET
        public string Index()
        {
            return "hello world";
        }

        public string Hello()
        {
            return "who's there?";
        }
    }
}

2.6.Adding View

<h1>Hello World Bro!</h1>
<p>This is the index page of hello world controller</p>
using System;
using System.Web.Mvc;

namespace FirstMVC.Controllers
{
    public class HelloWorldController : Controller
    {
        // GET
        public ActionResult Index()
        {
            return View();  
        }

        // ...
    }
}

2.7.Adding a Model or ViewModel


  目录