https://msdn.microsoft.com/en-us/library/4w3ex9c2.aspx
ASP.NET is a unified统一的 Web development model that includes the services necessary for you to build enterprise-class Web applications with a minimum of coding.
ASP.NET is part of the .NET Framework, and when coding ASP.NET applications you have access to classes in the .NET Framework.
You can code your applications in any language compatible with the common language runtime (CLR), including Microsoft Visual Basic and C#.
These languages enable you to develop ASP.NET applications that benefit from the common language runtime, type safety, inheritance, and so on.
If you want to try ASP.NET, you can install Visual Web Developer Express using the Microsoft Web Platform Installer, which is a free tool that makes it simple to download, install, and service components of the Microsoft Web Platform.
These components include Visual Web Developer Express, Internet Information Services (IIS), SQL Server Express, and the .NET Framework.
All of these are tools that you use to create ASP.NET Web applications.
You can also use the Microsoft Web Platform Installer to install open-source ASP.NET and PHP Web applications.
This topic describes the following features of ASP.NET and of Visual Web Developer, the development environment for creating ASP.NET applications.
The Three Flavors of ASP.NET: Web Forms, MVC, and Web Pages
ASP.NET offers three frameworks for creating web applications: ASP.NET Web Forms, ASP.NET MVC, and ASP.NET Web Pages.
All three frameworks are stable稳定的 and mature成熟的, and you can create great web applications with any of them.
Each framework targets a different audience or type of application.
Which one you choose depends on a combination of your web development experience, what framework you’re most comfortable with, and which is the best fit for the type of application you’re creating.
All three frameworks will be supported, updated, and improved in future releases of ASP.NET.
Here's an overview of each of the frameworks and some ideas for how to choose between them.
ASP.NET Web Forms (.aspx pages)
The Web Forms framework targets developers who prefer declarative and control-based programming, such as Microsoft Windows Forms (WinForms) and WPF/XAML/Silverlight.
It offers a WYSIWYG(What You See Is What You Get) designer-driven (drag-and-drop) development model,
so it's popular with developers looking for a rapid application development (RAD) environment for web development.
If you’re new to web programming and are familiar with the traditional Microsoft RAD(apid application development) client development tools (for example, for Visual Basic and Visual C#),
you can quickly build a web application without having expertise专门知识 in HTML and JavaScript.
In particular, the Web Forms model provides the following features:
-
An event model that exposes events which you can program like you would program a client application like WinForms or WPF.
-
Server controls that render HTML for you and that you can customize by setting properties and styles.
-
A rich assortment分类 of controls for data access and data display.
-
Automatic preservation保存 of state (data) between HTTP requests, which makes it easy for a programmer who is accustomed习惯于 to client applications to learn how to create applications for the stateless web.
Web Forms works well for small teams of Web developers and designers who want to take advantage of the large number of components available for rapid application development.
In general, creating a Web Forms application requires less programming effort than creating the same application by using the ASP.NET MVC framework.
The components (the Page class, controls, and so on) are tightly integrated and usually require less code than ASP.NET MVC applications.
However, Web Forms is not just for rapid application development.
There are many complex commercial apps and app frameworks built on top of Web Forms.
Because a Web Forms page and the controls on the page automatically generate much of the markup that's sent to the browser,
you don't have the kind of fine-grained细粒的 control over the HTML that the other ASP.NET models offer.
An event-driven, control-focused model hides some of the behavior of HTML and HTTP.
For example, it's not always possible to specify exactly what markup might be generated by a control.
The Web Forms model doesn't lend提供 itself as readily容易地 as ASP.NET MVC to patterns-based development, separation of concerns, and automated unit testing.
If you want to write code factored因式分解 that way, you can; it’s just not as automatic as it is in the ASP.NET MVC framework.
The ASP.NET Web Forms MVP project shows an approach方法 that facilitates separation of concerns and testability while maintaining the rapid development that Web Forms was built to deliver.
As an example of this in action, Microsoft SharePoint is built using Web Forms MVP.
ASP.NET MVC
ASP.NET MVC targets developers who are interested in patterns and principles like test-driven development, separation of concerns, inversion of control (IoC)控制反转, and dependency injection (DI).
This framework encourages separating the business logic layer of a web application from its presentation layer.
By dividing the application into the model (M), views (V), and controllers (C), ASP.NET MVC can make it easier to manage complexity in larger applications.
With ASP.NET MVC, you can have multiple teams working on a web site
because the code for the business logic is separate from the code and markup for the presentation layer —
developers can work on the business logic while designers work on the markup and JavaScript that is sent to the browser.
With ASP.NET MVC, you work more directly with HTML and HTTP than in Web Forms.
Web Forms tends to hide some of that by mimicking模仿 the way you would program a WinForms or WPF application.
For example, Web Forms can automatically preserve state between HTTP requests, but you have to code that explicitly in MVC.
The MVC model enables you to take complete control over exactly what your application is doing and how it behaves in the web environment.
MVC was designed to be extensible, providing power developers the ability to customize the framework for their application needs.
In addition, the ASP.NET MVC source code is available under an OSI license.
MVC 4 includes a feature that helps you develop HTTP services that reach a broad range of clients, including browsers and mobile devices.
For more information, see Getting Started with ASP.NET Web API.
MVC 4 also helps you develop single-page applications (SPAs) that use client-side JavaScript for responsive client interaction.
For more information, see Single Page Application Overview.
For more information about ASP.NET MVC, see ASP.NET MVC.
ASP.NET Web Pages (.cshtml and .vbhtml files)
ASP.NET Web Pages targets developers who want a simple web development story, along the lines of PHP.
In the Web Pages model, you create HTML pages and then add server-based code to the page in order to dynamically control how that markup is rendered.
Web Pages is specifically designed to be a lightweight framework, and it's the easiest entry point into ASP.NET for people
who know HTML but might not have broad programming experience — for example, students or hobbyists.
It's also a good way for web developers who know PHP or similar frameworks to start using ASP.NET.
Like Web Forms, Web Pages is oriented toward rapid development.
Web Pages provides components called helpers that you can add to pages and that let you use just a few lines of code to perform tasks that would either be tedious or complex.
For example, there are helpers to display database data, add a Twitter feed, log in using Facebook, add maps to a page, and so on.
Web Pages provides a simpler approach than Web Forms.
If you look at a .cshtml or .vbhtml file, you can generally think of the logic as executing top-to-bottom in the file, as you would with PHP, SHTML, etc.
And because .cshtml and .vbhtml files are essentially HTML files that have additional ASP.NET code in them, they lend themselves easily to adding client-side functionality via JavaScript and jQuery.
For more information about ASP.NET Web Pages, see ASP.NET Web Pages on the ASP.NET web site.
General Notes
All three ASP.NET frameworks are based on the .NET Framework and share core functionality of .NET and of ASP.NET.
For example, all three frameworks offer a login security model based around a membership API, and all three share the same facilities for managing requests, handling sessions, and so on that are part of the core ASP.NET functionality.
In addition, the three frameworks are not entirely independent, and choosing one does not preclude排除 also using another.
For example, MVC views are often written as .cshtml or .vbhtml files (using "Razor" syntax), which means they can take advantage of some of the Web Pages features like helpers.
Since the frameworks can also coexist共存 in the same web application, it's not uncommon to see individual components of an application written using different frameworks.
For example, the bulk of a site might be written in MVC, but the data access portion of the site might be written using Web Forms because it’s such an easy framework in which to perform data access.
In these cases, the developers choose the hybrid混合的 solution that plays to their strengths and makes their lives the easiest for their particular scenarios.
As of March 28, 2012, Microsoft has placed ASP.NET MVC 4, ASP.NET Web API, and ASP.NET Web Pages v2 (Razor syntax) under the open source Apache 2.0 license.
ASP.NET Web Forms is not included.
For more information, see ASP.NET MVC, Web API, Razor and Open Source(ScottGu’s blog) and ASP.NET MVC 4, ASP.NET Web API and ASP.NET Web Pages v2 (Razor) now all open source with contributions (Scott Hanselman’s blog).
The remaining sections of this topic provide an overview of ASP.NET features that are common to all three ASP.NET frameworks or unique to Web Forms.