This article is currently in the process of being translated into Thai (~6% done).
What is MVC?
MVC, ย่อมาจาก Model-view-controller, เป็นรูปแแบบซอฟท์แวร์ที่ได้รับการพัฒนาขึ้นในช่วงทศวรรษที่ 70 ชึ่งถือได้ว่าเป็นยุคต้นๆ ของการพัฒนาส่วนเชื่อมต่อกับผู้ใช้แบบกราฟฟิค (GUI) โดย MVC ได้พยายามแบ่งโปรแกรมออกเป็น 3 ส่วน
โมเดล (Model)
เป็นส่วนที่บรรจุข้อมูล และเงื่อนไขการทำงานต่างๆ สำหรับเว็บแอพพลิเคชั่นทั่วๆไป ส่วนนี้ของโปรแกรมมักจะหมายถึง ตาราง หรือ ฐานข้อมูล ซึ่งโปรแกรมต้องมีการเกี่ยวข้องด้วยในขณะใช้งาน
The View
The View is the actual visual representation of your Model. In a typical web application, this would be the page that shows your Model to the user, whether it be a form for inputting the data or an output of the data or a combination of both. Obviously, a View doesn't have to show all parts of the Model, and a Model can have more than one View.
The Controller
The Controller should handle all communication between your Model and your View. In a typical web application, the methods of the Controller are invoked by the user when a page is loaded or a button is clicked. The Controller then updates the Model, if necessary, and then returns a new View (or action, but more about that later), if necessary.
The Rise of MVC
After being introduced in the 1970's, the MVC pattern didn't get much attention for the next 30 years. Early web languages, like Perl, PHP and ASP Classic didn't really focus on design patterns and even with the release of ASP.NET, MVC was still not an integrated part of it. Sure, you could apply MVC techniques to your projects, but none of the popular frameworks encouraged it in any way.
Then, in 2004, the Ruby on Rails framework was released, which was a web development framework based on the Ruby language with heavy inspiration from the MVC pattern. A lot of people believe that this put the focus back on MVC and shortly thereafter, many PHP frameworks, centered around the MVC pattern, was released. All of this made the MVC pattern hugely popular, which is probably why Microsoft decided to do an implementation of it for their .NET framework, including massive tool support in their Visual Studio IDE. ASP.NET MVC was released in 2007, but the first final version didn't see the light of day before 2009.
In the next chapters, we will look deeper into what ASP.NET MVC is all about and how it compares to the alternatives, mainly ASP.NET WebForms.