ASP.NET 外文翻译.doc

上传人:啊飒飒 文档编号:10293356 上传时间:2021-05-06 格式:DOC 页数:10 大小:75.50KB
返回 下载 相关 举报
ASP.NET 外文翻译.doc_第1页
第1页 / 共10页
ASP.NET 外文翻译.doc_第2页
第2页 / 共10页
ASP.NET 外文翻译.doc_第3页
第3页 / 共10页
ASP.NET 外文翻译.doc_第4页
第4页 / 共10页
ASP.NET 外文翻译.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《ASP.NET 外文翻译.doc》由会员分享,可在线阅读,更多相关《ASP.NET 外文翻译.doc(10页珍藏版)》请在三一文库上搜索。

1、中原工学院信息商务学院毕业设计(论文)译文专用纸外文部分ASP.NET MVC .NET Framework 4The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.The ASP.NET MVC framework provides an alternative to the ASP.NET Web Forms pattern for creating W

2、eb applications.The ASP.NET MVC framework is a lightweight, highly testable presentation framework that (as with Web Forms-based applications) is integrated with existing ASP.NET features, such as master pages and membership-based authentication.The MVC framework is defined in theSystem.Web.Mvcassem

3、bly.MVC design patternMVC is a standard design pattern that many developers are familiar with.Some types of Web applications will benefit from the MVC framework.Others will continue to use the traditional ASP.NET application pattern that is based on Web Forms and postbacks.Other types of Web applica

4、tions will combine the two approaches; neither approach excludes the other.The MVC framework includes the following components: Models.Model objects are the parts of the application that implement the logic for the applications data domain.Often, model objects retrieve and store model state in a dat

5、abase.For example, aProductobject might retrieve information from a database, operate on it, and then write updated information back to a Products table in a SQL Server database.In small applications, the model is often a conceptual separation instead of a physical one.For example, if the applicatio

6、n only reads a dataset and sends it to the view, the application does not have a physical model layer and associated classes.In that case, the dataset takes on the role of a model object. Views.Views are the components that display the applications user interface (UI).Typically, this UI is created f

7、rom the model data.An example would be an edit view of a Products table that displays text boxes, drop-down lists, and check boxes based on the current state of aProductobject. Controllers.Controllers are the components that handle user interaction, work with the model, and ultimately select a view

8、to render that displays UI.In an MVC application, the view only displays information; the controller handles and responds to user input and interaction.For example, the controller handles query-string values, and passes these values to the model, which in turn might use these values to query the dat

9、abase.The MVC pattern helps you create applications that separate the different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling between these elements.The pattern specifies where each kind of logic should be located in the application.The UI l

10、ogic belongs in the view.Input logic belongs in the controller.Business logic belongs in the model.This separation helps you manage complexity when you build an application, because it enables you to focus on one aspect of the implementation at a time.For example, you can focus on the view without d

11、epending on the business logic.The loose coupling between the three main components of an MVC application also promotes parallel development.For example, one developer can work on the view, a second developer can work on the controller logic, and a third developer can focus on the business logic in

12、the model.Support for Test-Driven DevelopmentIn addition to managing complexity, the MVC pattern makes it easier to test applications than it is to test a Web Forms-based ASP.NET Web application.For example, in a Web Forms-based ASP.NET Web application, a single class is used both to display output

13、and to respond to user input.Writing automated tests for Web Forms-based ASP.NET applications can be complex, because to test an individual page, you must instantiate the page class, all its child controls, and additional dependent classes in the application.Because so many classes are instantiated

14、to run the page, it can be hard to write tests that focus exclusively on individual parts of the application.Tests for Web Forms-based ASP.NET applications can therefore be more difficult to implement than tests in an MVC application.Moreover, tests in a Web Forms-based ASP.NET application require a

15、 Web server.The MVC framework decouples the components and makes heavy use of interfaces, which makes it possible to test individual components in isolation from the rest of the framework.When to Create an MVC ApplicationYou must consider carefully whether to implement a Web application by using eit

16、her the ASP.NET MVC framework or the ASP.NET Web Forms model.The MVC framework does not replace the Web Forms model; you can use either framework for Web applications.(If you have existing Web Forms-based applications, these continue to work exactly as they always have.)Before you decide to use the

17、MVC framework or the Web Forms model for a specific Web site, weigh the advantages of each approach.Advantages of an MVC-Based Web ApplicationThe ASP.NET MVC framework offers the following advantages: It makes it easier to manage complexity by dividing an application into the model, the view, and th

18、e controller. It does not use view state or server-based forms.This makes the MVC framework ideal for developers who want full control over the behavior of an application. It uses a Front Controller pattern that processes Web application requests through a single controller.This enables you to desig

19、n an application that supports a rich routing infrastructure.For more information, seeFront Controller. It provides better support for test-driven development (TDD). It works well for Web applications that are supported by large teams of developers and for Web designers who need a high degree of con

20、trol over the application behavior.Advantages of a Web Forms-Based Web ApplicationThe Web Forms-based framework offers the following advantages: It supports an event model that preserves state over HTTP, which benefits line-of-business Web application development.The Web Forms-based application prov

21、ides dozens of events that are supported in hundreds of server controls. It uses a Page Controller pattern that adds functionality to individual pages.For more information, seePage Controller. It uses view state on server-based forms, which can make managing state information easier. It works well f

22、or 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, it is less complex for application development, because the components (thePageclass, controls, and so on) are tightly integrated and u

23、sually require less code than the MVC model.Features of the ASP.NET MVC FrameworkThe ASP.NET MVC framework provides the following features: Separation of application tasks (input logic, business logic, and UI logic), testability, and test-driven development (TDD).All core contracts in the MVC framew

24、ork are interface-based and can be tested by using mock objects, which are simulated objects that imitate the behavior of actual objects in the application.You can unit-test the application without having to run the controllers in an ASP.NET process, which makes unit testing fast and flexible.You ca

25、n use any unit-testing framework that is compatible with the .NET Framework. An extensible and pluggable framework.The components of the ASP.NET MVC framework are designed so that they can be easily replaced or customized.You can plug in your own view engine, URL routing policy, action-method parame

26、ter serialization, and other components.The ASP.NET MVC framework also supports the use of Dependency Injection (DI) and Inversion of Control (IOC) container models.DI enables you to inject objects into a class, instead of relying on the class to create the object itself.IOC specifies that if an obj

27、ect requires another object, the first objects should get the second object from an outside source such as a configuration file.This makes testing easier. Extensive support for ASP.NET routing, which is a powerful URL-mapping component that lets you build applications that have comprehensible and se

28、archable URLs.URLs do not have to include file-name extensions, and are designed to support URL naming patterns that work well for search engine optimization (SEO) and representational state transfer (REST) addressing. Support for using the markup in existing ASP.NET page (.aspx files), user control

29、 (.ascx files), and master page (.master files) markup files as view templates.You can use existing ASP.NET features with the ASP.NET MVC framework, such as nested master pages, in-line expressions (), declarative server controls, templates, data-binding, localization, and so on. Support for existin

30、g ASP.NET features.ASP.NET MVC lets you use features such as forms authentication and Windows authentication, URL authorization, membership and roles, output and data caching, session and profile state management, health monitoring, the configuration system, and the provider architecture.中文部分ASP.NET

31、 MVC 在订餐系统的作用.NET Framework 4模型-视图-控制器 (MVC) 体系结构模式将应用程序分成三个主要组件:模型、视图和控制器。ASP.NET MVC 框架提供用于创建 Web 应用程序的 ASP.NET Web 窗体模式的替代模式。ASP.NET MVC 框架是一个可测试性非常高的轻型演示框架,(与基于 Web 窗体的应用程序一样)它集成了现有的 ASP.NET 功能,如母版页和基于成员资格的身份验证。MVC 框架在System.Web.Mvc程序集中定义。MVC 设计模式MVC 是许多开发人员熟悉的标准设计模式。一些类型的 Web 应用程序将得益于 MVC 框架。一些

32、类型将继续使用基于 Web 窗体和回发的传统 ASP.NET 应用程序模式。其他类型的 Web 应用程序将结合这两种方法;这两种方法彼此互不包含。MVC 框架包括以下组件: 模型。模型对象是实现应用程序数据域逻辑的应用程序部件。通常,模型对象会检索模型状态并将其存储在数据库中。例如,Product对象可能会从数据库中检索信息,操作该信息,然后将更新的信息写回到 SQL Server 数据库内的 Products 表中。在小型应用程序中,模型通常是概念上的分离,而不是实际分离。例如,如果应用程序仅读取数据集并将其发送到视图,则该应用程序没有物理模型层和关联的类。在这种情况下,数据集担当模型对象的

33、作用。 视图。视图是显示应用程序用户界面 (UI) 的组件。通常,此 UI 是用模型数据创建的。Products 表的编辑视图便是一个视图示例,该视图基于Product对象的当前状态显示文本框、下拉列表和复选框。 控制器。控制器是处理用户交互、使用模型并最终选择要呈现的视图来显示 UI 的组件。在 MVC 应用程序中,视图仅显示信息;控制器则用于处理和响应用户输入和交互。例如,控制器处理查询字符串值,并将这些值传递给模型,而模型可能会使用这些值来查询数据库。MVC 模式可以帮助您创建使应用程序的不同方面(输入逻辑、业务逻辑和 UI 逻辑)分离的应用程序,同时可在这些元素之间提供松散耦合。该模式

34、指定每种逻辑在应用程序中应处的位置。UI 逻辑位于视图中。输入逻辑位于控制器中。业务逻辑位于模型中。在您生成应用程序时,通过使用这种分离方式,可以帮助您化繁为简,因为它可以使您侧重于一次实现应用程序的一个方面。例如,您可以侧重于独立于业务逻辑的视图。MVC 应用程序的这三个主要组件之间的松散耦合也可促进并行开发。例如,一个开发人员可以从事视图方面的工作,第二个开发人员可以从事控制器逻辑方面的工作,第三个开发人员可以侧重于模型中的业务逻辑。对测试驱动的开发的支持使用 MVC 模式除了可以化繁为简外,还可以使应用程序的测试工作比基于 Web 窗体的 ASP.NET Web 应用程序的测试工作更加轻

35、松。例如,在基于 Web 窗体的 ASP.NET Web 应用程序中,单一类既用于显示输出又用于响应用户输入。为基于 Web 窗体的 ASP.NET 应用程序编写自动化测试可能是一项复杂的工作,因为若要测试单个页面,您必须实例化应用程序中的页类、其所有子控件以及其他相关类。因为为运行页面而实例化的类如此之多,所以可能难以编写专门侧重于应用程序单个部件的测试。因此,与 MVC 应用程序测试相比,基于 Web 窗体的 ASP.NET 应用程序的测试更加难以实现。而且,基于 Web 窗体的 ASP.NET 应用程序的测试需要 Web 服务器。MVC 框架可使组件分离并大量使用接口,这样,便可以将单个

36、组件与框架的其余部分分开进行测试。何时创建 MVC 应用程序您必须仔细考虑是使用 ASP.NET MVC 框架还是使用 ASP.NET Web 窗体模型来实现 Web 应用程序。MVC 框架未取代 Web 窗体模型;您可以对 Web 应用程序使用任一框架。(如果您具有现有的基于 Web 窗体的应用程序,则这些应用程序将完全按照它们一贯的方式继续工作。)在决定对特定网站使用 MVC 框架或 Web 窗体模型之前,请权衡各种方法的优点。基于 MVC 的 Web 应用程序的优点ASP.NET MVC 框架具有以下优点: 通过将应用程序分为模型、视图和控制器,化繁为简的工作更加轻松。 它不使用视图状态

37、或基于服务器的窗体。这使得 MVC 框架特别适合想要完全控制应用程序行为的开发人员。 它使用一种通过单一控制器处理 Web 应用程序请求的前端控制器模式。这使您可以设计一个支持丰富路由基础结构的应用程序。有关更多信息,请参见Front Controller(前端控制器)。 它为测试驱动的开发 (TDD) 提供了更好的支持。 它非常适合大型开发人员团队支持的 Web 应用程序,以及需要对应用程序行为进行极度控制的 Web 设计人员。基于 Web 窗体的 Web 应用程序的优点基于 Web 窗体的框架具有以下优点: 它支持通过 HTTP 保留状态的事件模型,这有益于开发业务线 Web 应用程序。基

38、于 Web 窗体的应用程序提供了在数百个服务器控件中受支持的许多事件。 它使用页面控制器模式向单个页面添加功能。有关更多信息,请参见Page Controller(页面控制器)。 它针对基于服务器的窗体使用视图状态,这使得管理状态信息更加轻松。 它非常适合想要利用大量组件快速开发应用程序的 Web 开发人员和设计人员的小型团队。 通常,对于应用程序开发而言,它比较简单,这是因为组件(Page类、控件等)紧密集成并且通常需要比 MVC 模型更少的代码。ASP.NET MVC 框架的功能ASP.NET MVC 框架具有以下功能: 应用程序任务(输入逻辑、业务逻辑和 UI 逻辑)的分离、可测试性和测

39、试驱动的开发 (TDD)。MVC 框架中的所有核心协定都基于接口并且可使用 mock 对象进行测试,mock 对象是模仿应用程序中实际对象的行为的模拟对象。您可以对应用程序进行单元测试,而不必在 ASP.NET 进程中运行控制器,这使得单元测试既快速又灵活。您可以使用任何与 .NET Framework 兼容的单元测试框架。 可扩展和可插入的框架。设计 ASP.NET MVC 框架的组件的目的是为了可以轻松地替换或自定义它们。您可以插入自己的视图引擎、URL 路由策略、操作方法参数序列化以及其他组件。ASP.NET MVC 框架还支持使用依赖项注入 (DI) 和控制反转 (IOC) 容器模型。

40、DI 使您能够将对象注入到类中,而不是依靠类来创建对象本身。IOC 指定某个对象是否需要其他对象,第一个对象应该从配置文件之类的外部源中获取第二个对象。这样,测试会更加轻松。 广泛支持 ASP.NET 路由,ASP.NET 路由是一个功能强大的 URL 映射组件,它允许您生成具有易于理解和可搜索的 URL 的应用程序。URL 未必包含文件扩展名,并且旨在支持非常适合搜索引擎优化 (SEO) 和具象状态传输 (REST) 寻址的 URL 命名模式。 支持将现有 ASP.NET 页面(.aspx 文件)、用户控件(.ascx 文件)和母版页(.master 文件)标记文件中的标记用作视图模板。您可以将诸如嵌套母版页、内联表达式()、声明性服务器控件、模板、数据绑定、本地化等现有 ASP.NET 功能与 ASP.NET MVC 框架结合使用。 支持现有 ASP.NET 功能。ASP.NET MVC 允许您使用一些功能,如 Forms 身份验证和 Windows 身份验证、URL 授权、成员资格和角色、输出和数据缓存、会话和配置文件状态管理、运行状况监视、配置系统以及提供程序体系结构。 来源http:/

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 科普知识


经营许可证编号:宁ICP备18001539号-1