📅  最后修改于: 2023-12-03 14:39:22.501000             🧑  作者: Mango
ASP.NET MVC(Model-View-Controller)是微软推出的一种Web应用程序框架。与传统的WebForms开发框架不同,ASP.NET MVC采用了MVC模式(Model-View-Controller),将Web应用程序分为三个部分:模型(Model)、视图(View)和控制器(Controller)。这些部分各自负责不同的任务,让开发更加灵活和可维护。
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
public class PersonController : Controller
{
public ActionResult Index()
{
var people = new List<Person>
{
new Person { FirstName = "John", LastName = "Doe" },
new Person { FirstName = "Jane", LastName = "Doe" }
};
return View(people);
}
}
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
}