频道栏目
首页 > 资讯 > Python基础教程 > 正文

asp.net 2.0

22-09-16        来源:[db:作者]  
收藏   我要投稿

ASP.NET2.0 (ASP:Active Server Page) 是微软的。NET框架更新版本。NET2.0中的一部分,是一种重要的,流行的动态WEB开发技术。


基本信息

    中文名

    asp.net 2.0

    所    属

    微软

    发布时间

    2005年12月7日

    性    质

    .NET框架更新版本

目录     

1概念

2版本历史

3类似的技术

    

4WEB开发

5开发工具

6示例代码

    

7其他信息

8WEB资源

9更多介绍

折叠

编辑本段

概念

类似于PHP,JSP技术,ASP.NET 2.0版本发布于2005年12月7日。截止今天(2012/04/14),ASP.NET的最新版本为ASP.NET 4.5。

折叠

编辑本段

版本历史

说到ASP.NET 的版本,不得不一起说.NET框架的版本:

时间 .NET 版本 ASP.NET 版本

2002-02-13 1.0 1.0

2003-04-24 1.1 1.1

2005-11-07 2.0 2.0

2006-11-06 3.0 3.0

2007-11-19 3.5 3.5

2010-04-12 4.0 4.0

折叠

编辑本段

类似的技术

ASP.NET做为一门动态WEB开发技术,与之类似的技术有:PHP,JSP(Java Server Page),当然还有ASP.NET的前辈:ASP。

折叠

编辑本段

WEB开发

要使用ASP.NET 2.0 进行WEB开发,需要涉及到的相关技术主要有:

IIS (Internet Information Service) :它做为服务器端请求提供程序,B/S架构的S端。

一门编程语言,可以是C#, VB.NET,C++.NET,或者其它可以运行于.NET框架上的任何语言,甚至可以是相应的COBOL,PYTHON。

基本的HTML,JavaScript,DIV+CSS 当然也是必不可少的。

如果需要,可能会涉及到XML。另外还有这几年流行起来的Ajax技术(提供异步请求服务功能)。

另外,一般需要DB来提供后台数据存储服务,常用的有SQL SERVER,MY SQL ,ORACLE等。

折叠

编辑本段

开发工具

使用ASP.NET 2.0进行开发,最常用的,也是最方便的,最重要的工具,莫过于微软自身提供的Visual Studio 了,最新版本为Visual Studio 2010,但是2008及2005版本仍然有很多公司及开发人员在使用。使用这种IDE的最大好处就是方便,大大的提高了生产效率。当然仅仅使用NOTE PAD也可以编出像样的东西来,但是应该没有开发人员使用那种简单低效的方法进行开发。

另外,.NET 反编译工具 Reflector。可以将.NET 程序集反编译为源代码。

相关的版本控制工具: SVN, VSS , CVS 等。

相关的单元测试工具: NUnit 等。

折叠

编辑本段

示例代码

一个典型的ASP.NET2.0 WEB项目一般包括以下组成部分:

1:代码(以C#语言开发为例)

ASPX文件,是ASP.NET项目中的最常见的部分,它提供了WEB页面的布局控制方式。每一个ASPX文件一般通过代码分离技术,还跟一个ASPX.CS文件紧密相关,这就涉及到.NET2.0的PARTUAL CLASS功能。就是说一个类,可以分别定义在多个不同的文件中。以ASP.NET中的应用来看,这样提供了页面控件声明部分和后台处理部分代码的分离,结构更加清晰,易于维护。

ASCX文件,是ASP.NET项目中的用户控件定义文件。由ASP.NET提供的常规控件往往不能满足不同WEB项目的特定需要,我们经常需要个性化的控件样式,控件功能,或者控件捆绑复用。所以,开发自定义的用户控件是ASP.NET开发中的一项常见任务。同样,跟ASPX的页面分离技术一样,自定义的用户控件,也可以把与控件相关的属性定义,自定义方法分离到一个ASCX.CS文件中去。

ASAX文件,在ASP.NET的WEB请求处理流程中,有一些需要在每个请求中都进行处理的公共全局事件。一般会需要一个Global.Asax文件,模板示例如下,通过填充各个函数,可以进行各种全局处理。

折叠

编辑本段

其他信息

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.SessionState;

using System.Xml.Linq;

namespace MyWebProject

{

public class Global : System.Web.HttpApplication

{

protected void Application_Start(object sender, EventArgs e)

{

}

protected void Session_Start(object sender, EventArgs e)

{

}

protected void Application_BeginRequest(object sender, EventArgs e)

{

}

protected void Application_AuthenticateRequest(object sender, EventArgs e)

{

}

protected void Application_Error(object sender, EventArgs e)

{

}

protected void Session_End(object sender, EventArgs e)

{

}

protected void Application_End(object sender, EventArgs e)

{

}

}

}

ASHX 文件,当需要对WEB 请求处理流中的事件进行更加定制化的处理的时候,就需要处理HttpHandler相关的事件,这时候,需要生成 ASHX类型的文件。

ASMX文件,当需要进行WEB SERVICE相关的开发时,会使用到ASMX文件。

MASTER文件,模板文件,在一个项目中,你可能需要某一类页面具有一个相同的模板框架,然后不同页面填充不同的具体内容,这时候,就可以先定义模板文件,然后在各个页面中引用这个模板文件,可以减少重复开发。并且方便改变维护。示例如下:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MyWebProject.Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

<link id="Link1" type="text/css" rel="Stylesheet" href="css/General.css" />

<asp:ContentPlaceHolder ID="head" runat="server">

</asp:ContentPlaceHolder>

</head>

<body>

<form id="form1" runat="server">

<div id="MainContainer" >

<div id="Header">

<div id="LogoText">欢迎光临科学量子书店</div>

</div>

<br />

<div id="Caption">

<div id="HLink1">

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="Novel.aspx">小说</asp:HyperLink>

</div>

<div id="HLink2">

<asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="Poem.aspx">诗歌</asp:HyperLink>

</div>

<div id="HLink3">

<asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="Computer.aspx">计算机</asp:HyperLink>

</div>

<div id="HLink4">

<asp:HyperLink ID="HyperLink8" runat="server" NavigateUrl="MovieMusic.aspx">影音</asp:HyperLink>

</div>

</div>

<br />

<asp:ContentPlaceHolder ID="Main" runat="server">

</asp:ContentPlaceHolder>

</div>

</form>

</body>

</html>

2:资源文件

相关的资源文件,常见的便是图片文件,可以直接放在项目文件下面,然后在页面中引用

3:配置文件

主要的配置文件有 web.config , machine.config。

折叠

编辑本段

WEB资源

新手进行ASP.NET的学习,推荐书籍为:

ASP.NET 基础教程(Essential ASP.NET with Examples in C#) Fritz Onion著,清华大学出版社

ASP.NET高级程序设计(第3版)Mathew MacConald & Marie Szpuszte 著, 人民邮电出版社

折叠

编辑本段

更多介绍

ASP.NET is a programming framework built on the common language runtime that can be used on a server to build powerful Web applications. The first version of ASP.NET offered several important advantages over previous Web development models. ASP.NET 2.0 improves upon that foundation by adding support for several new and exciting features in the areas of developer productivity, administration and management, extensibility, and performance:

Developer Productivity

ASP.NET 2.0 encapsulates common Web tasks into application services and controls that can be easily reused across web sites. With these basic building blocks, many scenarios can now be implemented with far less custom code than was required in previous versions. With ASP.NET 2.0 it is possible to significantly reduce the amount of code and concepts necessary to build common scenarios on the web.

New Server Controls. ASP.NET 2.0 introduces many new server controls that enable powerful declarative support for data access, login security, wizard navigation, menus, treeviews, portals, and more. Many of these controls take advantage of core application services in ASP.NET for scenarios like data access, membership and roles, and personalization. Some of the new families of controls in ASP.NET 2.0 are described below.

Data Controls. Data access in ASP.NET 2.0 can be accomplished completely declaratively (no code) using the new data-bound and data source controls. There are new data source controls to represent different data backends such as SQL database, business objects, and XML, and there are new data-bound controls for rendering common UI for data, such as gridview, detailsview, and formview..

Navigation Controls. The navigation controls provide common UI for navigating between pages in your site, such as treeview, menu, and sitemappath. These controls use the site navigation service in ASP.NET 2.0 to retrieve the custom structure you have defined for your site.

Login Controls. The new login controls provide the building blocks to add authentication and authorization-based UI to your site, such as login forms, create user forms, password retrieval, and custom UI for logged in users or roles. These controls use the built-in membership and role services in ASP.NET 2.0 to interact with the user and role information defined for your site.

Web Part Controls. Web parts are an exciting new family of controls that enable you to add rich, personalized content and layout to your site, as well as the ability to edit that content and layout directly from your application pages. These controls rely on the personalization services in ASP.NET 2.0 to provide a unique experience for each user in your application.

Master Pages. This feature provides the ability to define common structure and interface elements for your site, such as a page header, footer, or navigation bar, in a common location called a "master page", to be shared by many pages in your site. In one simple place you can control the look, feel, and much of functionality for an entire Web site. This improves the maintainability of your site and avoids unnecessary duplication of code for shared site structure or behavior.

Themes and Skins. The themes and skins features in ASP.NET 2.0 allow for easy customization of your site's look-and-feel. You can define style information in a common location called a "theme", and apply that style information globally to pages or controls in your site. Like Master Pages, this improves the maintainability of your site and avoid unnecessary duplication of code for shared styles.

Personalization. Using the new personalization services in ASP.NET 2.0 you can easily create customized experiences within Web applications. The Profile object enables developers to easily build strongly-typed, sticky data stores for user accounts and build highly customized, relationship based experiences. At the same time, a developer can leverage Web Parts and the personalization service to enable Web site visitors to completely control the layout and behavior of the site, with the knowledge that the site is completely customized for them. Personalizaton scenarios are now easier to build than ever before and require significantly less code and effort to implement.

Localization. Enabling globalization and localization in Web sites today is difficult, requiring large amounts of custom code and resources. ASP.NET 2.0 and Visual Studio 2005 provide tools and infrastructure to easily build Localizable sites including the ability to auto-detect incoming locale's and display the appropriate locale based UI. Visual Studio 2005 includes built-in tools to dynamically generate resource files and localization references. Together, building localized applications becomes a simple and integrated part of the development experience.

Administration and Management

ASP.NET 2.0 is designed with administration and manageability in mind. We recognize that while simplifying the development experience is important, deployment and maintenance in a production environment is also a key component of an application's lifetime. ASP.NET 2.0 introduces several new features that further enhance the deployment, management, and operations of ASP.NET servers.

Configuration API. ASP.NET 2.0 contains new configuration management APIs, enabling users to programmatically build programs or scripts that create, read, and update Web.config and machine.config configuration files.

ASP.NET MMC Admin Tool. ASP.NET 2.0 provides a new comprehensive admin tool that plugs into the existing IIS Administration MMC, enabling an administrator to graphically read or change common settings within our XML configuration files.

Pre-compilation Tool. ASP.NET 2.0 delivers a new application deployment utility that enables both developers and administrators to precompile a dynamic ASP.NET application prior to deployment. This precompilation automatically identifies any compilation issues anywhere within the site, as well as enables ASP.NET applications to be deployed without any source being stored on the server (one can optionally remove the content of .aspx files as part of the compile phase), further protecting your intellectual property.

Health Monitoring and Tracing. ASP.NET 2.0 also provides new health-monitoring support to enable administrators to be automatically notified when an application on a server starts to experience problems. New tracing features will enable administrators to capture run-time and request data from a production server to better diagnose issues. ASP.NET 2.0 is delivering features that will enable developers and administrators to simplify the day-to-day management and maintenance of their Web applications.

Flexible Extensibility

ASP.NET 2.0 is a well-factored and open system, where any component can be easily replaced with a custom implementation. Whether it is server controls, page handlers, compilation, or core application services, you'll find that all are easily customizable and replaceable to tailor to your needs. Developers can plug in custom code anywhere in the page lifecycle to further customize ASP.NET 2.0 to their needs.

Provider-driven Application Services. ASP.NET 2.0 now includes built-in support for membership (user name/password credential storage) and role management services out of the box. The new personalization service enables quick storage/retrieval of user settings and preferences, facilitating rich customization with minimal code. The new site navigation system enables developers to quickly build link structures consistently across a site. As all of these services are provider-driven, they can be easily swapped out and replaced with your own custom implementation. With this extensibility option, you have complete control over the data store and schema that drives these rich application services.

Server Control Extensibility. ASP.NET 2.0 includes improved support for control extensibility, such as more base classes that encapsulate common behaviors, improved designer support, more APIs for interacting with client-side script, metadata-driven support for new features like themes and accessibility verification, better state management, and more.

Data Source Controls. Data access in ASP.NET 2.0 is now performed declaratively using data source controls on a page. In this model, support for new data backend storage providers can be easily added by implementing custom data source controls. Additionally, the SqlDataSource control that ships in the box has built-in support for any ADO.NET managed provider that implements the new provider factory model in ADO.NET.

Compilation Build Providers. Dynamic compilation in ASP.NET 2.0 is now handled by extensible compilation build providers, which associate a particular file extension with a handler that knows how to compile that extension dynamically at runtime. For example, .resx files can be dynamically compiled to resources, .wsdl files to web service proxies, and .xsd files to typed DataSet objects. In addition to the built-in support, it is easy to add support for additional extensions by implementing a custom build provider and registering it in Web.config.

Expression Builders. ASP.NET 2.0 introduces a declarative new syntax for referencing code to substitute values into the page, called Expression Builders. ASP.NET 2.0 includes expression builders for referencing string resources for localization, connection strings, application settings, and profile values. You can also write your own expression builders to create your own custom syntax to substitute values in a page rendering.

Performance and Scalability

ASP.NET is built to perform, using a compiled execution model for handling page requests and running on the world's fastest web server, Internet Information Services. ASP.NET 2.0 also introduces key performance benefits over previous versions.

64-Bit Support. ASP.NET 2.0 is now 64-bit enabled, meaning it can take advantage of the full memory address space of new 64-bit processors and servers. Developers can simply copy existing 32-bit ASP.NET applications onto a 64-bit ASP.NET 2.0 server and have them automatically be JIT compiled and executed as native 64-bit applications (no source code changes or manual re-compile are required).

Caching Improvements. ASP.NET 2.0 also now includes automatic database server cache invalidation. This powerful and easy-to-use feature allows developers to aggressively output cache database-driven page and partial page content within a site and have ASP.NET automatically invalidate these cache entries and refresh the content whenever the back-end database changes. Developers can now safely cache time-critical content for long periods without worrying about serving visitors stale data.

The remainder of the QuickStart presents practical examples of these and other features in ASP.NET.

asp.net是一个编程框架,建立在公共语言运行库,可用于在服务器上建立强大的Web应用程式。第一版本的asp.net提供了几个重要的优势超过以往的Web的发展模式。 asp.net 2.0好转后,在这个基础上加入支持一些新的和令人振奋的功能在以下领域的开发人员的工作效率,行政和管理,可扩展性,和业绩:

折叠

?工作效率

asp.net 2.0封装共同Web任务到应用服务和管制,可以很容易重复使用跨网站。与这些基本积木,很多情况下,现在可以实施,远不及自定义代码,比需要在先前的版本。与asp.net 2.0是有可能显着减少的金额代码和概念,必须建立共同的情况在网站上。

新的服务器控件。 asp.net 2.0引入了许多新的服务器控件,使强大的宣示支持数据访问,登录安全,向导导航,菜单, treeviews ,门户网站,和更多。许多这些控制利用为核心的应用服务在asp.net为情景一样,数据访问,成员和角色,和个性化。一些新的家庭控制在asp.net 2.0详述如下。

数据控制。数据访问,在asp.net 2.0能够做到完全以声明(没有code )使用新的数据绑定和数据源的控制。有新的数据源管制,以代表不同的数据,后端,如SQL资料库的企业, Business Objects ,和XML ,并有新的数据绑定控件的绘制共同的用户界面的数据,如gridview , detailsview , formview ..

导航控件。导航控件提供了共同的用户界面浏览页之间,在您的网站,如树视图,菜单,并sitemappath 。这些管制使用本网站的导航服务,在asp.net 2.0 ,以撷取自订的结构您已定义为您的网站。

登录管制。新的登录控件提供积木添加认证和授权为基础的用户界面到您的网站,如登录形式,创建用户的形式,密码检索,自定义用户界面,为记录在用户或角色。这些管制使用内置的成员和作用,服务在asp.net 2.0互动,与用户和作用,信息的定义为您的网站。

Web部件控制。 Web部件是一个令人振奋的新家庭的管制,使您可以添加丰富的,个性化的内容和布局到您的网站,以及有能力编辑的内容和布局,直接从您的应用程序的页面。这些管制依赖于个性化服务在asp.net 2.0提供了一个独特的经验,为每个用户在您的申请。

母版页。此功能可提供的能力,以确定共同的结构和界面元素为您的网站,如网页页眉,页脚,导航或酒吧,在一个共同的位置,称为"主页" ,共享很多的页面在您的网站。在一个简单的地方,你可以控制一看,觉得,很多的功能,为整个网站。这提高了可维护性您的网站,并避免不必要的重复代码共享网站结构或行为。

主题和外观。主题和外观特征,在asp.net 2.0允许轻松定制您的网站的外观和感觉。您可以定义样式信息在一个共同的位置,所谓的"主题" ,并套用样式信息在全球范围内的页面或控制在您的网站。想掌握的页面,这提高了可维护性您的网站,并避免不必要的重复代码共享的作风。

个性化。使用新的个性化服务在asp.net 2.0 ,您可以轻松创建自定义经验的Web应用程式。配置文件对象使开发人员能够轻松地帮助客户建立起强烈型,棘手的数据存储为用户帐户和建设高度定制的,基础的关系的经验。在同一时间内,开发商可以利用Web部件和个性化服务,使网站访问者,以完全控制的布局和行为的网站,与知识,该网站完全是为他们定制。 personalizaton情景,现在更容易建立比以往任何时候都需要显着较少的代码,并努力实施。

本地化。使全球化与本土化在网站今天是困难的,需要大量的自定义代码和资源。 asp.net 2.0和Visual Studio 2005提供的工具和基础设施,很容易建立本地化的网站,包括能力,自动侦测来袭的区域设置的,并显示适当的区域为基础的用户界面。 Visual Studio 2005中包括内建了一些工具来动态生成资源文件和本地化的参考。两者合计,建设本地化的应用,成为一个简单的和综合发展计划的一部分经验。

折叠

行政和管理

asp.net 2.0是设计与管理性和可管理性,在铭记。我们认识到,同时简化的发展经验是很重要的,部署和维护在生产环境中,也是一个关键组成部分,一个应用程序的寿命。 asp.net 2.0介绍了几种新功能,进一步加强部署,管理和运作asp.net服务器。

配置的空气污染指数。 asp.net 2.0中包含新的配置管理API ,使用户以编程方式建立的程序或脚本创建,读取和更新的Web.config和machine.config中配置文件。

asp.net的MMC管理工具。 asp.net 2.0提供了一种新的综合管理工具,插入现有的IIS管理MMC中,使管理员能够生动地读取或改变共同设置在我们的XML配置文件。

前汇编工具。 asp.net 2.0提供了一个新的应用程序部署实用工具,使双方开发人员和管理员,以precompile一个动态的asp.net应用在部署之前。这precompilation自动识别任何汇编的问题,任何地方的网站,以及使asp.net应用程序将要部署没有任何来源的被存储在服务器上(一可以选择性地删除的内容的。 aspx文件的一部分,该编译阶段) ,进一步保护您的知识产权。

健康监测和追踪。 asp.net 2.0也提供了新的健康监测的支持,以使管理员能够自动通知申请时,在服务器上开始遇到问题。新的追踪功能,将让管理者能捕获的运行时间和请求,将数据从生产服务器,以更好地诊断问题。 asp.net 2.0提供的功能,这将使开发人员和管理员,以简化的日常管理及维修他们的Web应用程序。

灵活的可扩展性

asp.net 2.0是一个良好的因素和公开的制度,任何组件可以很容易地取代自订的执行情况。无论是服务器控件,页处理,汇编,或为核心的应用服务,您会发现,都是很容易定制和更换,以度身订造的,以您的需求。开发人员可以堵塞在自定义代码的任何地方网页的生命周期,以进一步自定义asp.net 2.0到他们的需要。

供应商驱动的应用服务。 asp.net 2.0 ,现在包括内置支持,会员资格(用户名/密码认证存储)和管理服务的作用,走出方块。新的个性化服务可以快速存储/检索用户设置和偏好,促进丰富的个性化与最小的代码。新的网站导航系统使开发人员能够快速的建立链接的结构,始终跨越的网站。所有这些服务供应商为主导,他们可以很容易地换出,并代之以自己的自定义的执行情况。与此扩展选项,您有完整的控制权数据存储和架构的驱动器,这些丰富的应用服务。

服务器控件可扩展性。 asp.net 2.0包括改进的支持,控制可扩展性,如更多的基地班概括的共同行为,提高设计师的支持,更多的空气污染指数为互动与客户端脚本,元数据驱动的支持,新功能,如主题和无障碍的核查,更好的国家管理,以及更多。

数据源的控制。数据访问,在asp.net 2.0是现在的表现以声明使用的数据源控制在一个网页上。在此模型中,支持新的数据后端存储供应商可以很容易地说,通过实施自定义数据源的控制。此外, sqldatasource控制,船舶在方块中已内置支持,任何ado.net托管提供实现新的供应商工厂模型在ado.net 。

汇编,建立供应商。动态编译在asp.net 2.0是现在所处理的可扩展的汇编,建立供应商,其中协理特定文件扩展名与处理程序知道如何汇编这种扩展动态在运行时。举例来说, 。 resx文件可以被动态编译的资源, 。 WSDL文件,以Web Service的代理,和。为xsd文件类型化的DataSet对象。在除了内建的支持,很容易添加额外的支持,扩展实施自订的建立供应商和登记,它在Web.config中。

表达的建设者。 asp.net 2.0介绍了一种宣示性的新的语法参照代码来替代价值观融入网页,所谓表达的建设者。 asp.net 2.0包括表达的建设者为参照字符串资源的本地化,连接字符串,应用程序设置和个人的价值观。您也可以自己写表达的建设者,以创建自己的自定义语法来替代的价值在一个网页渲染。

折叠

性能与扩展性

asp.net是建立在执行,使用编译执行模型,为处理页的要求和运行于世界上速度最快的网络服务器, Internet信息服务。 asp.net 2.0还介绍了关键的性能优势,超过先前的版本。

64位支持。 asp.net 2.0是现在的64位启用,这意味着它可以充分利用内存地址空间的新的64位处理器和服务器。开发人员可以简单地复制现有的32位asp.net应用到一个64位asp.net 2.0服务器和他们自动JIT的编制和执行,作为本土的64位元应用程式(没有源代码的变化,或手动重新编译所需的) 。

缓存的改善。 asp.net 2.0现在还包括自动数据库服务器缓存失效。这个强大的和易于使用的功能,使开发人员能够积极输出缓存数据库驱动的网页和部分网页内容的网站,并已asp.net自动失效,这些缓存项,并刷新内容时,后端资料库的变化。发展商现在可以安全地缓存时间的关键内容长时间,无需担心服务旅客陈旧的数据。

其余的快速入门介绍了实际的例子,这些和其他功能在asp.net 。

相关TAG标签
上一篇: ASP.NET2.0
下一篇: Raspberry Pi用户指南
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站