ASP.NET 概述ASP.NET overview

ASP.NET 是一个免费的 web 框架, 用于使用 HTML、CSS 和 JavaScript 构建强大的网站和 web 应用程序。ASP.NET is a free web framework for building great websites and web applications using HTML, CSS, and JavaScript. 还可以创建 Web Api 并使用 Web 套接字等实时技术。You can also create Web APIs and use real-time technologies like Web Sockets.

ASP.NET Core是 ASP.NET 的一种替代方法。ASP.NET Core is an alternative to ASP.NET. 请参阅有关如何在 ASP.NET 与 ASP.NET Core 之间进行选择的指南See the guidance on how to choose between ASP.NET and ASP.NET Core.

入门Get started

安装Visual Studio 2017社区版, 适用于 Windows 上的 ASP.NET 的免费 IDE。Install Visual Studio 2017 Community edition, a free IDE for ASP.NET on Windows.

网站和 web 应用程序Websites and web applications

ASP.NET 提供了三个用于创建 web 应用程序的框架:Web 窗体、ASP.NET MVC 和 ASP.NET 网页。ASP.NET offers three frameworks for creating web applications: Web Forms, ASP.NET MVC, and ASP.NET Web Pages. 所有这三个框架都是稳定且成熟的, 你可以用其中任何一个框架创建优秀的 web 应用程序。All three frameworks are stable and mature, and you can create great web applications with any of them. 无论选择何种框架, 都可以在任何位置获得 ASP.NET 的所有优点和功能。No matter what framework you choose, you will get all the benefits and features of ASP.NET everywhere.

每个框架都以不同的开发样式为目标。Each framework targets a different development style. 选择哪一种取决于编程资产的组合 (知识、技能和开发经验)、要创建的应用程序类型, 以及你熟悉的开发方法。The one you choose depends on a combination of your programming assets (knowledge, skills, and development experience), the type of application you're creating, and the development approach you're comfortable with.

下面是每个框架的概述, 以及如何在它们之间进行选择的一些建议。Below is an overview of each of the frameworks and some ideas for how to choose between them. 如果你更喜欢视频简介, 请参阅使用 ASP.NET 生成网站什么是 Web 工具?If you prefer a video introduction, see Making Websites with ASP.NET and What is Web Tools?

如果你有经验If you have experience in 开发样式Development style 专业知识Expertise
Web Forms — Web 窗体Web Forms Win 窗体, WPF, .NETWin Forms, WPF, .NET 使用封装 HTML 标记的丰富控件库进行快速开发Rapid development using a rich library of controls that encapsulate HTML markup 中级、高级 RADMid-Level, Advanced RAD
MVCMVC Ruby on Rails, .NETRuby on Rails, .NET 完全控制 HTML 标记、代码和标记的分隔, 并易于编写测试。Full control over HTML markup, code and markup separated, and easy to write tests. 适用于移动和单页应用程序 (SPA) 的最佳选择。The best choice for mobile and single-page applications (SPA). 中级、高级Mid-Level, Advanced
网页Web Pages 经典 ASP, PHPClassic ASP, PHP 同一文件中的 HTML 标记和代码HTML markup and your code together in the same file 新的中级New, Mid-Level

Web Forms — Web 窗体Web Forms

使用 ASP.NET Web 窗体, 可以使用熟悉的拖放事件驱动模型构建动态网站。With ASP.NET Web Forms, you can build dynamic websites using a familiar drag-and-drop, event-driven model. 使用设计图面和数百个控件和组件, 您可以使用数据访问快速构建功能强大、功能强大的 UI 驱动站点。A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.

了解有关 Web 窗体的详细信息Learn more about Web Forms

MVCMVC

ASP.NET MVC 为你提供了一种功能强大的、基于模式的方法来构建动态网站, 使你能够轻松地分离问题并为你提供对标记的完全控制, 以实现愉快的敏捷开发。ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that enables a clean separation of concerns and that gives you full control over markup for enjoyable, agile development. ASP.NET MVC 包含许多功能, 可用于创建使用最新 web 标准的复杂应用程序的快速、TDD 友好的开发。ASP.NET MVC includes many features that enable fast, TDD-friendly development for creating sophisticated applications that use the latest web standards.

了解有关 MVC 的详细信息Learn more about MVC

ASP.NET 网页ASP.NET Web Pages

ASP.NET 网页和 Razor 语法提供一种将服务器代码与 HTML 组合在一起以创建动态 Web 内容的快速、易学的简便方法。ASP.NET Web Pages and the Razor syntax provide a fast, approachable, and lightweight way to combine server code with HTML to create dynamic web content. 连接到数据库, 添加视频, 链接到社交网络网站, 并提供更多的功能, 可帮助您创建符合最新 web 标准的精美站点。Connect to databases, add video, link to social networking sites, and include many more features that help you create beautiful sites that conform to the latest web standards.

详细了解网页Learn more about Web Pages

有关 Web 窗体、MVC 和网页的注释Notes about Web Forms, MVC, and Web Pages

所有三个 ASP.NET 框架都基于 .NET 和 ASP.NET 的 .NET Framework 和共享核心功能。All three ASP.NET frameworks are based on the .NET Framework and share core functionality of .NET and of ASP.NET. 例如, 所有三个框架都提供一个基于成员身份的登录安全模型, 而所有三个共享相同的功能来管理请求、处理会话等, 这是核心 ASP.NET 功能的组成部分。For example, all three frameworks offer a login security model based around membership, 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 using another. 由于框架可以共存于同一个 web 应用程序中, 因此查看使用不同框架编写的应用程序的各个组件并不少见。Since the frameworks can coexist in the same web application, it's not uncommon to see individual components of applications written using different frameworks. 例如, 应用程序的面向客户的部分可能在 MVC 中进行开发以优化标记, 而数据访问和管理部分则在 Web 窗体中开发, 以利用数据控件和简单的数据访问。For example, customer-facing portions of an app might be developed in MVC to optimize the markup, while the data access and administrative portions are developed in Web Forms to take advantage of data controls and simple data access.

Web APIWeb APIs

ASP.NET Web API 是一种框架, 可让你轻松地生成可访问范围广泛的客户端 (包括浏览器和移动设备) 的 HTTP 服务。ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API 是用于在 .NET Framework 上生成 RESTful 应用程序的理想平台。ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

详细了解 Web APILearn more about Web API

实时技术Real-time technologies

ASP.NET SignalR 是 ASP.NET 开发人员的新库, 使开发实时 web 功能变得更加容易。ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easier. SignalR 允许服务器和客户端之间的双向通信。SignalR allows bi-directional communication between server and client. 服务器可以立即将内容推送到连接的客户端。Servers can push content to connected clients instantly as it becomes available. SignalR 支持 Web 套接字, 并回退到旧版浏览器的其他兼容技术。SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR 包括用于连接管理的 Api (例如, 连接和断开连接事件)、分组连接和授权。SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.

了解有关 SignalR 的详细信息Learn more about SignalR

移动应用和站点Mobile apps and sites

ASP.NET 可以使用 Web API 后端为本机移动应用程序提供支持, 还可以使用 Twitter 启动等响应式设计框架来处理移动网站。ASP.NET can power native mobile apps with a Web API back end, as well as mobile web sites using responsive design frameworks like Twitter Bootstrap. 如果要生成本机移动应用, 可以轻松创建基于 JSON 的 Web API 来处理应用的数据访问、身份验证和推送通知。If you are building a native mobile app, it's easy to create a JSON-based Web API to handle data access, authentication, and push notifications for your app. 如果要构建一个响应迅速的移动站点, 则可以使用所需的任何 CSS 框架或打开的网格系统, 或使用 PhoneGap 选择一个功能强大的移动系统, 如 jQuery Mobile 或 Sencha 和出色的移动应用程序。If you are building a responsive mobile site, you can use any CSS framework or open grid system you prefer, or select a powerful mobile system like jQuery Mobile or Sencha and great mobile applications with PhoneGap.

了解有关移动应用和站点开发的详细信息Learn more about mobile app and site development

单页应用程序Single-page applications

ASP.NET 单页应用程序 (SPA) 可帮助你使用 HTML 5、CSS 3 和 JavaScript 构建包含重要客户端交互的应用程序。ASP.NET Single Page Application (SPA) helps you build applications that include significant client-side interactions using HTML 5, CSS 3 and JavaScript. Visual Studio 包含一个模板, 用于使用挖空和 ASP.NET Web API 生成单页面应用程序。Visual Studio includes a template for building single page applications using knockout.js and ASP.NET Web API. 除了内置的 SPA 模板以外, 还可下载社区创建的 SPA 模板。In addition to the built-in SPA template, community-created SPA templates are also available for download.

了解有关单页应用开发的详细信息Learn more about single-page app development

WebHookWebHooks

Webhook 是一种轻型 HTTP 模式, 它提供了一个简单的发布/订阅模型, 用于将 Web Api 和 SaaS 服务连线在一起。WebHooks is a lightweight HTTP pattern providing a simple pub/sub model for wiring together Web APIs and SaaS services. 当服务中发生事件时, 会以 HTTP POST 请求的形式向注册的订阅者发送通知。When an event happens in a service, a notification is sent in the form of an HTTP POST request to registered subscribers. POST 请求包含有关事件的信息, 使接收方可以相应地执行操作。The POST request contains information about the event which makes it possible for the receiver to act accordingly.

Webhook 由大量服务公开, 包括 Dropbox、GitHub、Instagram、MailChimp、PayPal、时差、Trello 等。WebHooks are exposed by a large number of services including Dropbox, GitHub, Instagram, MailChimp, PayPal, Slack, Trello, and many more. 例如, WebHook 可以指示在 Dropbox 中更改了某个文件, 或在 GitHub 中提交了代码更改, 或在 PayPal 中启动了一个付款, 或者在 Trello 中创建了一个卡。For example, a WebHook can indicate that a file has changed in Dropbox, or a code change has been committed in GitHub, or a payment has been initiated in PayPal, or a card has been created in Trello.

了解有关 Webhook 的详细信息Learn more about WebHooks