Model View Controller (MVC)

MVC is a thiết kế pattern used lớn decouple user-interface (view), data (model), và application xúc tích và ngắn gọn (controller). This pattern helps khổng lồ achieve separation of concerns.

Bạn đang xem: Asp

Using the MVC pattern for websites, requests are routed to a Controller that is responsible for working with the mã sản phẩm to perform actions and/or retrieve data. The Controller chooses the View to display and provides it with the Model. The View renders the final page, based on the data in the Model.

Learn more about the MVC pattern



ASP.NET gives you a powerful, patterns-based way lớn build dynamic websites using the MVC pattern that enables a clean separation of concerns.

Dig deeper: MVC with ASP.NET

public class Person public int PersonId get; set; public string Name get; set; public string PhoneNumber get; set; public string e-mail get; set;

Models & data

Create clean model classes & easily bind them to your database. Declaratively define validation rules, using C# attributes, which are applied on the client and server.

Xem thêm: 18 Best Bluetooth Multiplayer Games For Android, Bluetooth Game Controller

ASP.NET supports many database engines including SQLite, SQL Server, MySQL, PostgreSQL, DB2 & more, as well as non-relational stores such as MongoDB, Redis, và Azure Cosmos DB.

public class PeopleController : Controller private readonly AddressBookContext _context; public PeopleController(AddressBookContext context) _context = context; // GET: /people public async Task Index() return View(await _context.People.ToListAsync()); // GET: /people/details/5 public async Task Details(int id) var person = await _context.People.Find(id); if (person == null) return NotFound(); return View(person);


Simply route requests khổng lồ controller actions, implemented as normal C# methods. Data from the request path, query string, và request body are automatically bound lớn method parameters.

Dig deeper: Controllers with ASP.NET


Views with Razor

The Razor syntax provides a simple, clean, & lightweight way khổng lồ render HTML nội dung based on your view. Razor lets you render a page using C#, producing fully HTML5 compliant web pages.

Dig deeper: Views with ASP.NET

Ready lớn Get Started?

Our step-by-step tutorial will help you get MVC with ASP.NET running on your computer.