
BlueDragon 7.1: Deploying CFML on ASP.NET and the Microsoft .NET Framework 36
<%@ Page Language="c#" %>
<% System.Web.HttpRuntime.UnloadAppDomain(); %>
Restarted web app <%=
System.Web.HttpRuntime.AppDomainAppVirtualPath %>
at <%= System.DateTime.Now.ToShortTimeString() %>
Save this code into a file, perhaps called restart-webapp.aspx, and call it whenever you
want or need to restart the .NET web application. Note that in addition to unloading the .NET
web application, the code also displays the path of the application being restarted (discussed in a
moment) as well as the time of execution of this page.
Watch to make sure that the time shown indeed reflects the current time, to help you ensure that
you’re not seeing the cached output of a previous execution of the page from your browser.
Simply refresh the page to see the current time.
The next request for a .NET page (CFML or ASPX, for instance) will restart the application
(with the expected delay that occurs on the first request of any new .NET page, as explained in
section 7.1.3).
Remember also that each web site, virtual directory, or directory declared in IIS to be an appli-
cation is its own web application, as discussed in section 6.5, so it’s important that you run this
code in the docroot (or one of its subdirectories) of the intended web application. That’s why
the code also displays the path to the web application, to help you ensure you’re restarting your
intended application.
You could also execute the same .NET method using CFML:
<cfobject action="create" type=".NET"
class="System.Web.HttpRuntime" name="rt">
<cfset rt.UnloadAppDomain()>
<cfoutput>
Restarted web app #rt.get_AppDomainAppVirtualPath()# at
#timeformat(now())#
</cfoutput>
One problem with this approach of running the request as a CFML page, however, is that if the
CFML runtime engine (BlueDragon) is not responding for any reason, such a CFM page may not
run, where an ASPX page should always run.
Komentarze do niniejszej Instrukcji