Using the Redirect method, you can redirect the browser to another URL instead of sending the content to the user. For example, if you want to verify that users have entered your application from the home page so that they can receive a customer ID, you can verify that they have a customer ID number, and if not, you can redirect it to the home page. Here's a concrete example:
<%if session ("CustomerID") = 0 Then Response.Redirect ' homepage.asp ' End if%>
Unless the buffer is open, you must redirect the browser before any content or title is returned to the browser. Placing the Response.Redirect statement before the top of the page and the tag ensures that nothing is returned to the browser. If you use Response.Redirect after returning to the content or title of the browser, you will see an error message.
If you use Response.Redirect in the middle of a page, use it with the Response.Buffer property because, by default, the WEB server returns HTML and the script processing results when processing ASP pages. However, you can set the Response object's Buffer property to process All server script commands on the page before sending any content to the user.
You can use buffering techniques to determine a point in the page process, and you do not want to send the content before that point to the user. You can also redirect the user to another page using the Redirect method of the Response object, or clear the buffer with the Response object's clean method and send different content to the user. The following examples use both of these methods.
Example one:
<% ' Next program must be placed in the program before the identifier Response.Buffer = True%> ...
Example two:
<%if Request ("FName") = "Then response.clear Response.Redirect". /test.html "Else Response.Write Request (" FName ") End if%>
The above is the function that the response object often uses in the program.
The server object has those attribute methods and how to use the
The server object provides methods and properties that are accessible to servers. Most of these methods and properties are provided as functionality of the utility.
What are the basic properties and methods of the server object?
(1). Grammar:
Server.property|method
(2). Attribute (property)
The server object has only one property: The maximum time a scripttimeout program can run
(3). Method (Methods)
CreateObject establishes an object instance.
Execute executes an ASP file
GetLastError returns an error code
HTMLEncode converts the specified HTML code.
MapPath converts a relative path to an absolute path.
Transfer sends all current status information to another ASP file
UrlEncode converts the specified code, including spaces, as a URL
How do I use the properties and methods of the server object?
(1). CreateObject
Grammar
Server.CreateObject (ProgID)
Parameters
ProgID
Specifies the name of the component to be created, in the following format: [Vendor.] component[. Version].
Points:
In general, the lifetime of objects created with the Server.CreateObject method is within the scope of the page. This means that when this page's ASP program is finished, the object automatically disappears.
In order to create an object that has a session or application range, you will use the CreateObject method in the Global.asa file