Simple building of ASP. NET Ajax environment (zt)

Source: Internet
Author: User
Tags configuration settings
1 Overview

Microsoft ASP. NET Ajax is Microsoft's perfect encapsulation of Ajax technology. It allows you to quickly create web pages that contain rich user experience, and provide client scripts that include cross-browser ecmascript (JavaScript) and dynamic HTML (DHTML) technology, and with the server-based 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.. Net Client/Server Components and types are automatically converted, and the server is automatically exposed to the client.CodeProvides remote web service with many beautiful functions such as local client proxy. Using ASP. net ajax can improve the applicationProgramUser 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 andCommunityProvides 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 the Ajax application framework for developing and running server-centric or client-centric development models, which is fully supported by Microsoft. You must install ASP. NET futures or ASP. NET Ajax toolkit before installing it. In addition, you can download the ASP. NET Ajax document (not required), which contains examples that can 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. It makes development easier than Ajax 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 ures (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 installation

The installation sequence is to first install ASP. NET 2.0 Ajax Extensions 1.0, 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 package, you can see an additional "ASP. net Ajax-enabled web site, which can be used to create a newly configured Ajax website, as shown in Figure 2:

Figure 2 new website dialog box
[/Align]

4 Configuration

ASP.. Net Ajax configuration is often used for ASP that was previously developed and does not use Ajax. NET application, but understand these configurations, for the use of ASP. net Ajax is also essential.
This section briefly introduces all configuration elements and describes them in detail in future use.

4.1 Use the ASP. NET Ajax web configuration file in the new web site

When creating a new ASP. NET Ajax web site, you can use the web. config file provided in the installation package to add configuration settings. In Visual Studio, the Web. config file for Microsoft ASP. NET Ajax is included in the project when you create an "ASP. NET Ajax-enabled web site.
If you want to manually add a web. config to the newly created web site, you can obtain a copy of it from the installation directory and copy it to the root directory of the site. By default, the file is placed in the following locations:
Drive: "Program Files" Microsoft ASP. NET "ASP. NET 2.0 Ajax extensions" v1.0.nnnn

4.2 Add ASP. NET Ajax configuration elements to an existing web site

For an existing site, some values are usually reserved. 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 <configsections> element

The <configsections> element creates a configuration section and a sub-configuration section for the systemwebextensionssectiongroup class. You can set attributes 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 as a child element of the <configuration> element. For more information, see 4.2.6 <system. Web. Extensions>.

Code:

<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 <controls> element

<Controls> the element registers the ASP. NET Ajax namespace in the system. Web. Extensions assembly and maps 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 ASP.. Net Ajax <controls> element. You can add this section to an existing web. as <system. A child element of the Web> <pages> element:

Code:

<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 <assemblies> element

<Assemblies> the element registers the system. Web. Extensions assembly.
The following example shows ASP.. Net Ajax <assemblies> element, you can add this section to an existing web. as <system. A child element of the Web> <compilation> element:

Code:

<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

<Httphandlers> adds a new handler for script requests.
The following example shows ASP.. Net Ajax

Code:

<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 ASP.. Net Ajax

Code:

<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 <system. Web. Extensions> element

The <system. Web. Extensions> element provides elements for configuring how to call Web Services in Microsoft ASP. NET Ajax applications. The <jsonserialization> element specifies the customized type converter to overwrite the default JSON serialization settings. The <converters> element specifies the customized type converter. The <authenticationservice> 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. The <scriptresourcehandler> element is used to make the cache available or unavailable, and to compress resources used by the script.
The <scriptresourcehandler> element, <authenticationservice> element, and <profileservice> element can only be defined in the web. config file under the machine. config file or application root directory. The <jsonserialization> element can also be defined in Web. config under the sub-folder of the web site.
The following example shows ASP. net Ajax <system. web. extensions> element. You can add this section to an existing web. as a sub-element of the <configuration> element in the config file:

Code:

<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 users to obtain or modify personalized attributes in ASP. NET Ajax applications,
You need to add the name of each attribute to the readaccessproperties and writeaccessproperties attributes. -->
<! --
<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 <system. webserver> element

The <system. webserver> element contains configuration settings for Microsoft Internet Information Service (IIS) 7.0.
The following example shows ASP. net Ajax <system. webserver> element. You can add this section to an existing web. as a sub-element of the <configuration> element in the config file:

Code:

<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...
» Broadcast [FM: + ¦ íöbbs .51aspx.com û ë á§ done"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.