ASP Web pages in the. NET Framework Environment (2) (Wangguorong)

Source: Internet
Author: User
Tags config html tags range reference web services
ado+ and Data Control components

The Data library Access object provided by the. NET Framework is called ado+ (Active Data object+), although there are a lot of ideas and ADO similar, but it is a new object, why have ADO, but also to provide ado+? There may be several reasons why the pen feels:
  • Use XML as a data exchange format: Since XML has become the standard for Internet Exchange data, this is a forced move to take.
  • Extending the range of data: Under ADO, any data has to be accessed through old DB or ODBC, and ado+ has no such limit, and any program can help ado+ provide the object to become the provider of the new data format, thus extending the range of accessible data.
  • Integration with Data Control components: the most inconvenient place in the past when we wrote the ASP Web was the contents of the data library, in order to display the contents of the library, it is necessary to read and record the data by helping the ADO recordset, and then display it in a pen, the program is more redundant, In the ASP.net Web page, we simply place the DataGrid, DataList, or Repeater, and then connect with ado+, and control elements such as the DataGrid will automatically display the contents of the library. 5 and 6 is the use of the DataGrid and DataList control components to display the content of the Web page.

Map-5 http://www.kjedu.com.tw/kjaspx/ch01/AspxPage.aspx Web pages
Map-6 http://www.kjedu.com.tw/kjaspx/ch01/DataList.aspx Cache and Performance improvement

To improve performance, ASP. NET Web pages are first translated into MSIL storage drives, the next time the Web page is accessed again, you can directly execute the stored MSIL (please refer to the "performance of the suspect" paragraph), in addition to this enhanced performance of the action, ASP. NET provides the cache (cache memory) function can also improve performance. Asp. NET provides the cache function into output cache and data cache two kinds.

Output cache and Web quick fetch



Map-7 Output cache and Web quick access

7, the so-called output cache, after the MSIL is performed, the results are written into the output cache, and then upload the output cache to the browser, and if you browse the same Web, ASP. NET will first determine whether the Web page has output cache exists, if so, the direct upload of output cache to the browser, not through the translation of. aspx and the process of MSIL, so can improve performance.
The way to activate the output cache is simple, as long as you add the following tag to the front of the. aspx Web:

<%@ OutputCache duration= "seconds"%>

Where duration represents the number of seconds that the output cache retains in the system, for example:

<%@ OutputCache duration= "Ten"%>

The output cache for the results page will remain in the system for 10 seconds, and whenever you browse this Web page in 10 seconds, ASP. NET will directly upload the output cache to the browser, omitting the translation of the motion.

Data cache and Data quick Fetch


In addition to storing the entire Web page in output cache, we can also store local data in the cache (below). The use of cache is similar to application objects, for example:

' Store data or objects in a Application object
Application ("Key1") = "This is a string"
Application ("Key2") = obj

' Store data or objects in the cache
Cache ("Key1") = "This is a string"
Cache ("Key2") = obj

What the pen has to say is that the memory that is occupied by the data cache may be released at any time (the scenario used by the memory system), so every time we want to read the data cache, we have to first judge whether the cache ("key") is equal to nothing, if it is not equal to nothing, Indicates that the cache ("key") is still in the system before it can be read.
Provide bug tools

In the process of writing a program, it is difficult to make mistakes, and how to do so is an important and unavoidable task for any programming designer. ASP's bug tool is very deficient, in order to improve this missing, ASP. NET offers the following kinds of bug methods:
  • Set the Config.web customerrors
  • Using Tracking (Trace) features
  • Bug Tool Program (Debugger)

Set the Config.web customerrors


When the Web page is wrong and cannot be translated or performed, ASP. NET shows a picture of 8, which only tells us that the program is wrong, and that the line of the program is wrong and not shown. In order to allow ASP.net to display the error message, you can add the setting of customerrors section in the Config.web file, as follows:

<configuration>
<customerrors mode= "Off"/>
</configuration>

The results will be followed by a more detailed error indicating screen (Figure 9)
Diagram-8 ASP. NET Web to translate or perform a wrong painting
diagram-9 ASP. NET to translate or perform the wrong drawing (Error message details) (image)

Using the Trace tracker feature


The trace function is the front of the web with the following logo:

<%@ Page trace= "True"%>

After the results are shown, we will show you some information, such as Figure 10, which will help us to judge the status of the program as a reference to the bug.
Image -10 The Web page after the trace feature is enabled (thumbnail)
In picture-10, in addition to the normal contents of the Web page, the additional information can be divided into the following sections:
  • Request Details: The information that is read to the browser through the request method.
  • Trace information: The process of an event or program.
  • Controlling tree: The hierarchical relationship between control elements and control elements used on the web.
  • Cookies Collection: Cookies used on Web pages.
  • Headers Collection: Table information for the browser.
  • Server variables:server variables, which we can pass through request. The information that ServerVariables () read.

In addition to allowing ASP.net to display the above message, we can also display data from the program's process in the trace Information section by calling Trace.Write or Trace.Warn, for example:

Trace.Write ("UploadFile ()", "Enter UploadFile Event program")
Trace.Warn ("UploadFile ()", "Enter for Loop")

The results can be output to the trace Information section for our reference to the reconnaissance program.

Bug Tool Program (Debugger)


Asp. NET provides the debugger program very much like the VB operation interface, may let us set the point point, the step-by-step procedure, the observation change and the stack situation ... And so on, is the detective wrong weapon. Before using debugger, add the following settings to the Config.web file:

<compilation debugmode= "true"/>

Then activate the DbgUrt.exe of the C:\Program files\microsoft.net\frameworksdk\guidebug, and then use the following steps to detect the. aspx Web:
1. Select the "debug-> processes" of the DbgUrt.exe function table, when "processes" talk window is selected, the "show system processes" and "show processes in All sessions", then find Xspwp.exe at the bottom of the"available processes"(note: If you don't see Xspwp.exe, first activate the browser to browse to any. aspx Web page and then press the"refresh"button) After selecting, then press the "attach" button, the process is like-11.
Chart -11 DbgUrt.exe "process" window (pictured)
2. The "attach to process" conversation window (pictured-12) is then pressed, please press the "ok" button.
Diagram -12 Attach to Process conversation window (pictured)
3. Then go back to the "processes" conversation window of Step 1 and press the "close" button.
4. Select the "file-> Open-> file" the DbgUrt.exe menu to select the. aspx file you want to detect, where you can select more than one file you want to scout.
the development of the object

Due to the asp.net of VB7 as a programming language, so VB7 all of the object-directed functions can also be displayed in the ASP.net Web page, and in addition to the object-oriented features provided by the programming language, ASP.net can develop a web-focused object-Pagelet (Web Gadget).
What is Pagelet (Web Accessories)? In the case of life, when we decorate the Christmas tree, tend to buy gadgets, and then put them in a favorite place, and Pagelet's views are similar, some commonly used accessories, we can design pagelet, let the other web to use, for a more realistic example, For example, a label control element and a TextBox control element are placed in our web page to insert a label type Pagelet and a TextBox type Pagelet in the web.
This article lets the pen person first show a simple pagelet, this one pagelet is named Footer.ascx, as follows: (registration: Pagelet must use. ascx name)

<div align= "Right" >
<Hr>
<a href= "http://www.kj.com.tw" target= "_top" >
Learn visual Basic to find King's glory </A>
</Div>

If you look at the contents of the Footer.ascx, you will find that there are only HTML tags, and there is no ASP.net program at all. Can the ascx file be pagelet? The answer is yes, the simplest pagelet is only HTML-labeled. ascx file, and then let's take a look at the Web page that uses this pagelet usefoot.aspx:

<%@ Register tagprefix= "kj" tagname= "Footer" src= "Footer.ascx"%>
<Html>
<body bgcolor= "White" >
<H3> Use the simplest pagelet--usefoot.aspx<Blockquote>
If you look at the contents of the Footer.ascx, you will find that there are only HTML tags, completely without
asp+ program, so. Can the ascx file be a pagelet? The answer is yes.
, the simplest pagelet is only an HTML-labeled. ascx file.
</Blockquote>
<kj:footer id= "Footer1" runat= "Server"/>
</Body>
</Html>

Web browsing results like 13.

Map -13 usefoot.aspx The results of the browse

In addition to containing only the simplest pagelet of HTML, Pagelet can also contain attributes and methods, which are used in the same way as the server control elements for pagelet that contain the attributes and methods. When we feel the server control components provided by the. NET Framework are not enough, we can build our own server control components using the Pagelet feature.
Web Services

Unlike ASP Web pages, you can access only the library, ASP. NET provides Web services functionality that allows us to access remote sources across the Internet. In the VB6, the Micro Software developed RDS (Remote Data Service), it also allows us to access another server's library on the internet, but it still has two major missing points: (1) The average user is not easy to get to (2) can not cross the platform: Use RDS to access the data library across the Internet, The Windows operating system must be used regardless of server or client side.
Web Services (Web service) improves the lack of RDS, in addition to making it easier to get started, Web Services uses XML as a data transmission format that enables data to span platforms, and more importantly, ASPs. NET Web page can also enjoy this service, but also to provide this service.
In the business model, let the pen take a practical example, please refer to 14, the browser will access the Web page of server A, but server A's data library from Serverx, then Server X to provide a access to the data library of the website Service, on the other hand, server A is to create a Web repository agent, and then access the server x library through the Web repository agent and the Web service's data exchange (in XML format).

14 Access Web Data library (across the internet's library)
language

Maybe the Sansang is really overrated, but the web's technology has become the knowledge that the information people have to equip. Although the ASP has been underestimated since it came from the micro-Microsoft table IIS, it is only an attached product of IIS, and now I'm glad ASP.net finally came out of the IIS, and functions with VB, C # ... As a programming language, I believe that the future ASP Web will enter another brand new century.


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.