Plenty of people have asked how they can manually force global.asa to fire, without stopping and starting the web server or application. They already know they can't hit global.asa directly with a browser; this ends up in a 500-15 HTTP Error (Requests for global.asa not allowed).
There is a way around this. This example will deal with forcing the application_onStart() routines to fire, without disrupting the server.
The trick is to keep the logic in an #include file, and store that as an ASP page you can hit manually. Yes, many people aren't aware that you can #include a file in global.asa, but you certainly can. Here is some syntax within global.asa:
<script language=vbscript runat=server> sub application_onStart() </script> <!--#include virtual='/admin/start-app.asp'--> <script language=vbscript runat=server> end sub </script>
|
The trick is that both global.asa and the #include file must have matching script types... no <%%> delimiters. The ASP page should also include straight script (no subs or functions) and not use any response-related methods. So your start-app.asp file should look like this:
<script language=vbscript runat=server> ' do stuff ' insert into database ' set application variables ' etc etc. </script>
|
Now this code will fire in the application_onStart() event, but you can also override it by hitting http://yourserver/admin/start-app.asp as well.
This is very handy; however, I first employed this technique back during one of the first global.asa-related security exploits.
[ Comment, Edit or Article Submission ]