home *** CD-ROM | disk | FTP | other *** search
-
- <%@ Register TagPrefix="Acme" TagName="SourceRef" Src="/quickstart/util/SrcRef.aspx"%>
-
- <!-- #include virtual="/quickstart/aspplus/include/header.inc" -->
-
- <h4>Application Overview</h4>
-
- <div class="indent" style="font-family:Verdana; font-size:8pt;">
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#what">What is an ASP+ Application ?</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#creating">Creating an Application</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#lifetime">Lifetime of an Application</a><br>
- <b> <img align="middle" src="/quickstart/images/bullet.gif"> </b>
- <a class="toc2" target="content" href="#multiplethreads">A Note on Multiple Threads</a><br>
- </div>
-
- <p>
- <hr>
-
- <!--BEGIN SECTION-->
- <a name="what">
- <span class="subhead">What is an ASP+ Application ?</span>
- <p>
-
-
- ASP+ defines an application as the sum of all files, pages, handlers, modules
- and executable code that can be invoked or run in the scope of a given virtual
- directory (and its subdirectories) on a web application server. For example,
- an "order" application might be published via the "/order" virtual directory on a
- web server computer. For IIS the virtual directory can be set up via the Internet
- Services Manager and contains all subdirectories, unless they are virtual directories
- themselves.
- <p>
-
-
- Each ASP+ application on a web server is executed within a unique NGWS runtime
- <b>Application Domain</b> - guaranteeing class isolation (no versioning/naming conflicts),
- security sandboxing (preventing access to certain machine/network resources),
- and static variable isolation.
- <p>
-
- ASP+ maintains a pool of HttpApplication instances over the course of a web
- application's lifetime. ASP+ automatically assigns one of these instances to
- process each incoming HTTP request that is received by the application.
- The particular HttpApplication instance assigned is responsible for managing
- the entire lifetime of the request, and is only re-used after the request has
- been completed. This means that user code within it does not need to be
- re-entrant.
- <p>
-
-
-
- <!--BEGIN SECTION-->
- <a name="creating">
- <span class="subhead">Creating an Application</span>
- <p>
-
- To create an ASP+ application you can use an existing virtual directory or
- create a new one. For example, if you installed Windows 2000 Server including
- IIS, you probably have a directory C:\InetPub\WWWRoot. You can configure IIS
- using the Internet Services Manager, available under
- Start <nobr>-></nobr> Programs <nobr>-></nobr> Administrative Tools.
- Right-Click on an existing directory and choose either New (to create a new
- virtual directory) or Properties (to promote an existing regular directory).
- <p>
-
- By placing a simple .aspx page like the following in the virtual directory and hitting it with the browser, you trigger
- the creation of the ASP+ application.
-
- <div class="code"><pre>
- <%@Page Language="C#"%>
- <html>
- <body>
- <h1>hello world, <% Response.Write(DateTime.Now.ToString()); %></h1>
- </body>
- </html>
- </pre></div>
-
- Now you can add appropriate code to use
- the <a href="stateoverview.aspx">Application</a> object, for example to store
- objects with application scope. By creating a
- <a href="globalasax.aspx">global.asax</a> file you can define various event handlers,
- e.g. for the Application_OnStart event.
- <p>
-
- <!--BEGIN SECTION-->
- <a name="lifetime">
- <span class="subhead">Lifetime of an Application</span>
- <p>
-
- An ASP+ application is created the first time a request is made to the server, before
- that no ASP+ code is executing. Upon receiving the first request, a pool of HttpApplication
- instances is created, and the Application_OnStart event is fired. The HttpApplication
- instances process this and subsequent requests, until the last instance exits and the
- Application_OnEnd event is fired.
- <p>
-
- Note, that the Init and Dispose methods of HttpApplication are called per instance and
- thus can be called several times between Application_OnStart and Application_OnEnd. Only
- these events are shared among all instances of HttpApplication in one ASP+
- application.
- <p>
-
-
-
- <!--BEGIN SECTION-->
- <a name="multiplethreads">
- <span class="subhead">A Note on Multiple Threads</span>
- <p>
-
- If you use objects with application scope, you should be aware that
- ASP+ processes requests concurrently and the Application object can be
- accessed by multiple threads. So the following code is dangerous and will probably
- not produce the expected result, if the page is requested several times from
- different clients at the same time:
-
- <div class="code"><pre>
- <%
- Application["counter"] = (Int32)Application["counter"] + 1;
- %>
- </pre></div>
-
- To make code thread-safe, the access of the Application object can be serialized
- via the Lock and UnLock methods. This of course means accepting a considerable
- performance hit:
- <div class="code"><pre>
- <%
- Application.Lock();
- Application["counter"] = (Int32)Application["counter"] + 1;
- Application.UnLock();
- %>
- </pre></div>
-
- Another solution is to make the object itself stored with application scope
- thread-safe. Note, that for example the collection classes in the System.Collections namespace
- are not thread-safe for performance reasons.
- <p>
-
- <h4>Section Summary</h4>
- <ol>
- <li>ASP+ applications consist of everything living under one virtual directory of the web server.
- <li>Create an ASP+ application by adding files to a virtual directory on the web server.
- <li>The lifetime of an ASP+ application is marked by Application_OnStart and Application_OnEnd.
- <li>Access of application-scope objects must be safe for multi-threaded access.
- </ol>
- <p>
-
-
- <!-- #include virtual="/quickstart/aspplus/include/footer.inc" -->
-
-
-
-
-
-
-
-
-