2025-04-27 07:49:33 -04:00

100 lines
6.8 KiB
HTML
Raw Blame History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>Application Control Techniques</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_k2_application_control_techniques"></A><SUP></SUP>Application Control Techniques</H2>
<P>ASP provides six different ways to affect the general flow of execution. These six methods are depicted in the following diagrams. The arrows in the diagrams represent the flow of execution.</P>
<H4>Redirecting</H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_redir.gif" ALT="Process Flow - Redirection" BORDER=0></P>
<P>Redirection is the process of diverting a request to another location. Redirecting requires a new request to be sent to the server. However, in general, you should design your application to minimize the amount of communication between the client and server. Many design problems that have been addressed by redirecting in the past can now be accomplished by transferring, which does not initiate a new request. See <A HREF="/iishelp/iis/htm/asp/eadg9947.htm">Coordinating Client/Server Processing</A> for more information on this aspect of application design.</P>
<P>You can accomplish redirecting by using the <A HREF="/iishelp/iis/htm/asp/vbob8h10.htm"><B>Response.Redirect</B></A> method.</P>
<H4>Transferring </H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_trans.gif" ALT="Process Flow - Transfer" BORDER=0></P>
<P>The ability to transfer a request from one ASP page to another was introduced in IIS&nbsp;5.0. Transferring is similar to redirecting; however, it does not require that a new request be initiated. This is a much more efficient way to control application flow. If you transfer the request to an ASP page outside of the application boundary, the boundary will be temporarily extended to include the external ASP page. The external ASP page will behave as if it were included within the application boundary of the calling ASP page. Therefore, any objects or variables that have been given application scope will still be available in the ASP page to which you have transferred. In addition to being faster than redirecting, transferring preserves all of the ASP built-in objects from the original request, including form values from an HTTP post.</P>
<P>You can accomplish transferring by using the <A HREF="/iishelp/iis/htm/asp/vbob9waa.htm"><B>Server.Transfer</B></A> method.</P>
<H4>Executing</H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_exec.gif" ALT="Process Flow - Execute" BORDER=0></P>
<P>The ability to execute a particular ASP script and return the result was introduced in IIS&nbsp;5.0. Executing is similar to a procedure call in most programming languages. This method of application flow control is appropriate if you have developed an ASP application that accomplishes some function that you want to incorporate, but have not built that function into a component.</P>
<P>You can accomplish executing by using the <A HREF="/iishelp/iis/htm/asp/vbob9pid.htm"><B>Server.Execute</B></A> method.</P>
<H4>Component Invocation </H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_comp.gif" ALT="Process Flow - Component Invocation" BORDER=0></P>
<P>This is probably the most common way to control the flow of an application. The COM programming model is integral to the Windows DNA, and should address the vast majority of design problems. Script Components, a technology supported in IIS&nbsp;5.1, make it easier to take existing scripts and convert them to components.</P>
<P>You can accomplish component invocation by using the <A HREF="/iishelp/iis/htm/asp/vbob0ss4.htm"><B>Server.CreateObject</B></A> method. For more information on script components, see <A HREF="/iishelp/iis/htm/asp/eadg12ib.htm">Windows Script Components</A> and <A HREF="iiwacomu.htm">Using Components and Objects</A>.</P>
<H4>Exiting</H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_exit.gif" ALT="Process Flow - Exiting" BORDER=0></P>
<P>Under normal circumstances you will want your ASP application to complete each line of script in the page. There may be some circumstances, however, where you will need to simply end the response. For example, if you have detected&nbsp; (by using the <A HREF="/iishelp/iis/htm/asp/vbob1d0k.htm"><B>Response.IsClientConnected</B></A> method) that the client is no longer waiting for a response, you will want to terminate the ASP application.</P>
<P>You can accomplish exiting the ASP by using the <A HREF="/iishelp/iis/htm/asp/vbob2sis.htm"><B>Response.End</B></A> method.</P>
<H4>Procedural Processing</H4>
<P><IMG SRC="/iishelp/iis/htm/asp/art/pf_proc.gif" ALT="Process Flow - Procedures" BORDER=0></P>
<P>If you want to define subroutines or functions within your .asp file, you can do so by using the procedure syntax that is appropriate for the scripting language you are using. For example, VBScript defines subroutines with the <B>Sub <20> End Sub</B> syntax and functions with the <B>Function <20> End Function</B> syntax. JScript, on the other hand, supports procedural processing through function calls. For more information on subroutine processing, see <A HREF="iiwaproc.htm">Writing Procedures</A>.</P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>