1 Overview Microsoft ASP. NET Ajax is Microsoft's perfect encapsulation of Ajax technology. It allows you to quickly create a user interface that contains rich user experience
Web pages provide client scripts that are added with cross-browser ecmascript (JavaScript) and dynamic HTML (DHTML) technologies.
ASP. NET 2.0 platform is integrated. It also cleverly extends the object-oriented aspects of JavaScript to provide support for Object-Oriented Programming on the client side.
Automatic conversion of Client/Server Components and types closely integrated with ASP. NET; Automatic Exposure of server end for client Code For the remote Web Service
Provides many elegant functions such as local client proxy. Using ASP. net ajax can improve the application Program User Experience and efficiency.
ASP. NET Ajax is cached by the client script library and server components to provide a robust development framework. In addition to ASP. NET Ajax, you can also use ASP. NET
Ajax Control Toolkit and Community Provides ASP. NET Ajax ures features.
Shows the architecture of ASP. NET Ajax:
Figure 1 ASP. NET Ajax server and client architecture
2 download
Required components of ASP. NET Ajax include:
ASP. NET
2.0 Ajax Extensions 1.0: download and install Ajax for developing and running server-centric or client-centric development models
Framework of the class application, which is fully supported by Microsoft. Install ASP. NET futures or ASP. NET Ajax Toolkit
You must install it before. You can also download ASP. NET
Ajax documentation (not required) contains examples that help you use ASP. NET ajax to the maximum extent possible.
ASP. NET
Ajax Control Toolkit: A Shared Source Code Community Project composed of examples and components, which enables development to use Ajax
It is easier to develop controls and extensions. Control Toolkit provides runnable examples and rich sdks to simplify the creation of custom Ajax controls and extensions.
Optional components include: ASP. NET
Futures (July 2007)
, ASP. NET
2.0 Ajax Extensions 1.0 source code
Sample Application
And
Microsoft
Ajax library, which can be downloaded as needed.
3 install and install ASP. NET 2.0 Ajax Extensions 1.0 first, and then ASP. NET Ajax Control
Toolkit, and then install other components. You only need to click Next for all installation steps.
After installing the required component package, you can see an additional "ASP. NET Ajax-enabled web site" in the "Create a website" dialog box. With this, you can create a newly configured Ajax
Website, 2:
Figure 2 new website dialog box
4. configuring ASP. NET Ajax is often noticed when used in previously developed ASP. NET applications that do not use Ajax.
ASP. NET Ajax is also essential.
This section briefly introduces all configuration elements and describes them in detail in future use.
4.1 use ASP. net Ajax web configuration file when creating a new ASP. net Ajax web site, you can use the web provided in the installation package. config file to add configuration settings. In Visual Studio
The Web. config file for Microsoft ASP. NET Ajax is being created in the "ASP. NET Ajax-enabled web
Site is included in the project.
If you want to manually add a web. config to the newly created web
Site, you can get a copy of it from the installation directory, copy it to the site's root directory. By default, the file is placed on the drive: "Program Files" Microsoft ASP. NET "ASP. NET 2.0 Ajax extensions" v1.0.nnnn
4.2 Add ASP. net Ajax configuration elements to existing web sites for an existing site, there are usually some values to be retained, in this case, you can add a new ASP.. Net Ajax configuration elements to existing web. config.
The new elements are components of the following configuration sections:
- <Configsections> element
- <Controls> element
- <Assemblies> element
- <Httphandlers> element
- <Httpmodules> element
- <System. Web. Extensions> element
- <System. webserver> element
4.2.1 The <configsections> element <configsections> creates a systemwebextensionssectiongroup
Class configuration section and sub-configuration section, you can set properties for these sections in the <system. Web. Extensions> element.
The following example shows the <configsections> element used for ASP. NET Ajax. You can add it to an existing web. config file
<Configuration> child element of the element. For more information, see 4.2.6 <system. Web. Extensions>. <Configuration>
<Configsections>
<Sectiongroup name = "system. Web. Extensions"
Type = "system. Web. configuration. systemwebextensionssectiongroup,
System. Web. Extensions,
Version = 1.0.61025.0, culture = neutral,
Publickeytoken = 31bf3856ad364e35 ">
<Sectiongroup name = "scripting"
Type = "system. Web. configuration. scriptingsectiongroup,
System. Web. Extensions,
Version = 1.0.61025.0, culture = neutral,
Publickeytoken = 31bf3856ad364e35 ">
<Section
Name = "scriptresourcehandler"
Type = "system. Web. configuration. scriptingscriptresourcehandlersection,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral, publickeytoken = 31bf3856ad364e35"
Requirepermission = "false"
Allowdefinition = "machinetoapplication"/>
<Sectiongroup
Name = "WebServices"
Type = "system. Web. configuration. scriptingwebservicessectiongroup,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral, publickeytoken = 31bf3856ad364e35 ">
<Section
Name = "jsonserialization"
Type = "system. Web. configuration. scriptingjsonserializationsection,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral, publickeytoken = 31bf3856ad364e35"
Requirepermission = "false" allowdefinition = "everywhere"/>
<Section
Name = "profileservice"
Type = "system. Web. configuration. scriptingprofileservicesection,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral, publickeytoken = 31bf3856ad364e35"
Requirepermission = "false"
Allowdefinition = "machinetoapplication"/>
<Section
Name = "authenticationservice"
Type = "system. Web. configuration. scriptingauthenticationservicesection,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral, publickeytoken = 31bf3856ad364e35"
Requirepermission = "false"
Allowdefinition = "machinetoapplication"/>
</Sectiongroup>
</Sectiongroup>
</Sectiongroup>
</Configsections>
</Configuration>
4.2.2 The <controls> element <controls> is registered with ASP. NET Ajax in the system. Web. Extensions assembly.
Namespace, and map ASP to these namespaces to mark prefix aliases. Controls in ASP. Net Ajax namespaces can be used on web pages in the following forms:
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
The following example shows the <controls> element used for ASP. NET Ajax. You can add this section to an existing web. config file
A child element of the <system. Web> <pages> element:
<System. Web>
<Pages>
<Controls>
<Add tagprefix = "asp"
Namespace = "system. Web. UI" assembly = "system. Web. Extensions,
Version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
</Controls>
</Pages>
</System. Web>
4.2.3 The <assemblies> element <assemblies> registers the system. Web. Extensions assembly.
The following example shows the <assemblies> element used for ASP. NET Ajax. You can add this section to an existing web. config file
A child element of the <system. Web> <compilation> element:
<System. Web>
<Compilation>
<Assemblies>
<Add Assembly = "system. Web. Extensions,
Version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
</Assemblies>
</Compilation>
</System. Web>
To debug this assembly, you can add the <compilation> property DEBUG = "true ".
4.2.4 Add a new handler for script requests to the The following example shows the <System. Web> A child element of an element: <system. Web>
<Httphandlers>
<Remove verb = "*" Path = "*. asmx"/>
<Add verb = "*" Path = "*. asmx" Validate = "false"
Type = "system. Web. Script. Services. scripthandlerfactory,
System. Web. Extensions,
Version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
<Add verb = "*" Path = "* _ appservice. axd" Validate = "false"
Type = "system. Web. Script. Services. scripthandlerfactory,
System. Web. Extensions,
Version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
<Add verb = "Get, head" Path = "scriptresource. axd"
Type = "system. Web. Handlers. scriptresourcehandler,
System. Web. Extensions,
Version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35"
Validate = "false"/>
</Httphandlers>
</System. Web>
4.2.5 The The following example shows the <System. Web> A child element of an element: <system. Web>
<Httpmodules>
<Add name = "scriptmodule"
Type = "system. Web. Handlers. scriptmodule, system. Web. Extensions,
Version = 1.0.61025.0, culture = neutral,
Publickeytoken = 31bf3856ad364e35 "/>
</Httpmodules>
</System. Web>
4.2.6 The <system. Web. Extensions> element <system. Web. Extensions> allows you to configure how to call the Web
Service Element. <Jsonserialization> the element specifies a customized type converter to overwrite the JSON
The default settings for serialization. The <converters> element specifies the customized type converter. <Authenticationservice>
The element is used to make the identity authentication service available or unavailable. The <profileservice> element is used to make the personalized information service available or unavailable, and specify the properties exposed by the Service. <Scriptresourcehandler>
Elements are used to make the cache available or unavailable, and are compressed by the resources used by the script.
<Scriptresourcehandler> element, <authenticationservice>
The element and <profileservice> element can only be defined in the machine. config file or the web. config under the application root directory.
File. The <jsonserialization> element can also be defined in Web. config under the sub-folder of the web site.
The following example shows the <system. Web. Extensions> element used for ASP. NET Ajax. You can add this section to an existing
In the Web. config file, as a child element of the <configuration> element:
<System. Web. Extensions>
<Scripting>
<WebServices>
<! -- Customize maxjsonlength and add a custom JSON Conversion Program. -->
<! --
<Jsonserialization maxjsonlength = "500">
<Converters>
<Add
Name = "convertme"
Type = "Acme. subacme. convertmetypeconverter"/>
</Converters>
</Jsonserialization>
-->
<! -- Make the argument service available. If appropriate, include requiressl = "true"
. -->
<! --
<Authenticationservice enabled = "true"
Requiressl = "True | false"/>
-->
<! -- Make personalized services available. To allow
Get or modify personalized attributes in the application,
You need to add the names of each attribute to readaccessproperties and
Writeaccessproperties attribute. -->
<! --
<Profileservice enabled = "true"
Readaccessproperties = "propertyname1, propertyname2"
Writeaccessproperties = "propertyname1, propertyname2"/>
-->
</WebServices>
<! -- Enable compression or caching of client script files. -->
<! --
<Scriptresourcehandler enablecompression = "true"
Enablecaching = "true"/>
-->
</Scripting>
</System. Web. Extensions>
4.2.7 The <system. webserver> element <system. webserver> contains the configuration settings used for Microsoft Internet Information Service (IIS) 7.0.
The following example shows the <system. webserver> element used for ASP. NET Ajax. You can add this section to an existing web. config
File as a sub-element of the <configuration> element: <system. webserver>
<Validation validateintegratedmodeconfiguration = "false"/>
<Modules>
<Add name = "scriptmodule"
Precondition = "integratedmode"
Type = "system. Web. Handlers. scriptmodule,
System. Web. Extensions, version = 1.0.61025.0, culture = neutral,
Publickeytoken = 31bf3856ad364e35 "/>
</Modules>
<Handlers>
<Remove name = "WebServiceHandlerFactory-ISAPI-2.0"/>
<Add name = "scripthandlerfactory" verb = "*"
Path = "*. asmx"
Precondition = "integratedmode"
Type = "system. Web. Script. Services. scripthandlerfactory,
System. Web. Extensions, version = 1.0.61025.0, culture = neutral,
Publickeytoken = 31bf3856ad364e35 "/>
<Add name = "scripthandlerfactoryappservices" verb = "*"
Path = "* _ appservice. axd"
Precondition = "integratedmode"
Type = "system. Web. Script. Services. scripthandlerfactory,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral,
Publickeytoken = 31bf3856ad364e35 "/>
<Add name = "scriptresource"
Precondition = "integratedmode"
Verb = "Get, head" Path = "scriptresource. axd"
Type = "system. Web. Handlers. scriptresourcehandler,
System. Web. Extensions, version = 1.0.61025.0,
Culture = neutral,
Publickeytoken = 31bf3856ad364e35 "/>
</Handlers>
</System. webserver>
5. Summary
In general, building an ASP. NET Ajax development environment is still very simple. Well, let's get started with Ajax...