ASP 3.0 new Features sneak peek

Source: Internet
Author: User
Tags execution iis new features client
If you are using Win2000 and IIS5.0 now, then you can realize that ASP 3.0
The new changes brought about by ...
ASP 3.0 is not particularly altered in relation to ASP 2.0, which is the ASP version in IIS 4.0.
But it also brings some very distinctive enhancements, let's take a look at these new features:
Server.Transfer
This is a new way to control another ASP page from the current ASP page.
It can be used to replace the Response.Redirect method.
An example is provided:
Suppose you want to relocate the user to another new URL after performing some processing.
If you are in as 2.0, your execution process is like this, first execute your process and then use the
Response.Redirect the user back to the URL. The problem with this approach is Response.Redirect
Too bloated (too inefficient to perform)-because this is the first way to send the client's browser a
Message telling the browser that it is now time to relocate to a new URL. And then the browser reads this
Request, and then return a message to the server, requesting the server to locate itself in that URL, and finally
The server will process the new request and pass the HTML to the client.

As can be seen from the above process, a response.redirect leads to a lot of network traffic.
And Server.Transfer is to solve this problem and appear, it can be simply understood as a service-side
URL relocation, that is, it is directly on the server can relocate the URL, without having to do with the client
Too much communication to avoid aggravating network traffic.
The following is a simple example:
' Perform the process you need
...
' Relocate the user to doneprocessing.asp
Server.Transfer "/scripts/doneprocessing.asp"

Server.Execute
? This execute method is somewhat similar to the transfer method described above, but the difference is that the Execute method
will give control to the calling ASP page when the called ASP page finishes execution.
Oh, is not a bit confused ah, let the example to illustrate the problem:
Suppose the code for Page1.asp is as follows:
Response.Write "Hello,"
Server.Execute "Page2.asp"
Response.Write "World!"

And the Page2.asp code is as follows:
Response.Write "Good morning!"

When browsing page1.asp through a browser, the first output is Hello to the client.
Then, the page2.asp is executed, and the result is the good morning! Output to the client.
Finally, control goes back to where Page1.asp left off, and the result is the world! Output to the client.
The result that the client can see at the end is:

Hello, Good morning! World!??

For all this, the client did not know that Page1.asp called page2.asp, and that the browser did not
Relocate or refresh because all of this is done on the server side. This article describes an entirely new built-in object ASPError object in ASP 3.0.
ASPError Object
This new, built-in and ASP 3.0 object provides a previous version of the
Specifically used to handle the wrong object, so that we can manipulate the error to be possible.
Previously you could use the on Error Resume next or JScript in VBScript to try ... Catch to catch the error,
But you cannot capture a COM object, or an error that occurs in a built-in ASP object
But if you use the ASPError object, then everything will be possible to change.

To use this object, the first thing we need to do is to customize the HTTP error message in IIS (how do I say no more
10 times, hehe. )。 This triggers the HTTP error 500;100 when an ASP-related error message occurs.

Then in the ASP script you can access the ASPError object to determine exactly what is wrong.
The ASPError object has a series of read-only properties to get the details of the last error.
This service-side object contains a new method GetLastError that must be used to obtain the occurrence of the
Error message.

Now let's take the example to illustrate the problem, assuming that the script file used to handle the error is catcherror.asp.
You should first set the HTTP 500;100 in the custom error message for IIS to reposition with catcherror.asp.
The error message is then displayed in its own way, as follows: following code:
<%
Dim Objlastasperror
Set Objlastasperror = Server.GetLastError
%>

Caught an error:<br>
Error description: <%=objLastASPError.Description%><BR>
Error Category: <%=objLastASPError.Category%><BR>
Error file: <%=objLastASPError.File%><BR>
Error Number: <%=objLastASPError.Number%><BR>


ASPError objects, Server.Transfer, Server.Execute are new in ASP 3.0
Content. Of course, there are some other minor changes. For example, the default Response.Buffer in ASP 2.0 is set to False.
In ASP 3.0, Response.Buffer is set to True by default.

Of course, the latest version of the scripting engine (both VBScript and JScript) comes with ASP 3.0


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.