§1.1 A Brief History of Web Development
时间段 技术 优点 缺点 Jurassic Common Gateway Interface (CGI) Simple
Flexible
Only option at the timeRuns outside the
web server, so is
resource intensive
(spawns separate OS
process per request)
Low-levelBronze age
Microsoft Internet Database
Connector (IDC)Runs inside web server Just a wrapper for
SQL queries and
templates for
formatting result sets1996 Active Server Pages (ASP) General-purpose 2002/03 ASP.NET Web Forms 1.0/1.1 Compiled
“Stateful” UI
Vast infrastructure
Encourages objectoriented
programmingHeavy on bandwidth
Ugly HTML
Untestable2005 ASP.NET Web Forms 2.0 2007 ASP.NET AJAX 2008 ASP.NET Web Forms 3.5 2009 ASP.NET MVC 1.0 2010 ASP.NET MVC 2.0
ASP.NET Web Forms 4.0
In just the same way, ASP.NET MVC 1 was designed to tackle the specific shortcomings of traditional ASP.NET, but this time by trying to emphasize simplicity.
Traditional ASP.NET Web Forms
ASP.NET was a huge shift when it first arrived. Figure 1–1 illustrates Microsoft’s new technology stack as
it first appeared in 2002.
What’s Wrong with ASP.NET Web Forms?
Traditional ASP.NET Web Forms was a fine idea, and a thrilling prospect at first, but of course reality turned out to be more complicated. Over the years, real-world use of Web Forms uncovered a range of weaknesses:
- ViewState weight
- Page life cycle
- False sense of separation of concerns
- Limited control over HTML
- Leaky abstraction
- Difficulty applying automated tests
§1.2 Web Development Today
Web Standards and REST
Web sites are consumed on a greater variety of devices and browsers than ever before, and web standards (for HTML, CSS, JavaScript, etc.) remain our one great hope for getting a decent browsing experience everywhere—even on the Internet-enabled refrigerator.
At the same time, REST3 has become the dominant architecture for application interoperability over HTTP, completely overshadowing SOAP( the technology behind ASP.NET’s original approach to Web Services). Today’s web applications don’t just serve HTML—equally often they must also serve JSON or XML data to various client technologies including Ajax, Silverlight, and native smartphone applications.
Agile and Test-Driven Development
The .NET open source and independent software vendor (ISV) community has produced no end of top-quality unit testing frameworks (NUnit, xUnit), mocking frameworks (Moq, Rhino Mocks), inversion-of-control containers (Ninject, AutoFac), continuous integration servers (Cruise Control,TeamCity), object-relational mappers (NHibernate, Subsonic), and the like; and proponents of these tools and techniques have even found a common voice, publishing and organizing conferences under the shared brand ALT.NET. Traditional ASP.NET Web Forms is not very amenable to these tools and techniques because of its monolithic design, so from this vocal group of experts and industry thought leaders, Web Forms gets little respect.
Ruby on Rails
Ruby on Rails transforming the rules of web development. It’s not so much that it contained revolutionary technology,
§1.3 Key Benefits of ASP.NET MVC
MVC Architecture
ASP.NET MVC directly answers the competition of Ruby on Rails and similar platforms, bringing this style of development into the mainstream of the .NET world, capitalizing on the experience and best practices discovered by developers using other platforms, and in many ways pushing forward beyond what even Rails can offer.
Extensibility
……………………