Jump to content

How Many Global.asa files can I have on a web site


Recommended Posts

I am struggling to understand the proper positioning of the global.asa file on an existing web site to which I am adding a shopping cart facility. Currently I have a global.asa file sitting in the root directory of the web site which contains just one item in the 'Session_OnStart' sub routine to set a security level for acess. In the same root directory there is a .asp page which, on successful login, changes the session security level and alters the timeout period from the default of 20 minutes to allow logged in users adequate time to browse the shop. Also in the same root directory are a number of contact form asp pages but these do not amend the security level - they have no need to. At this moment I should point out that browsing the site does not require users to login, but they will need to in order to claim discounts on purchases. The shopping cart part of the web site is being developed from a commercially available one and is based round an Access database. The authors (and copyright holders) supply the system with a license that permits substantial customisation to integrate with an existing site. With their system comes a global.asa file which contains entries for the 'application_OnStart', 'session_OnStart', and 'session_OnEnd' sub routines but, suprisingly, nothing for the 'application_OnEnd' sub routine. The shopping cart asp pages are being located in a Shop sub-directory of the web site so as to keep them segregated from pages not relevant to the shop. The shop page files in the Shop directory are all named with a .asp name. The instructions from the cart supplier clearly states "The global.asa file needs to be in the root directory of the MetaCart ASP web application." Now comes the point where confusion sets in. On http://www.w3schools...p_globalasa.asp it clearly states "The Global.asa file must be stored in the root directory of the ASP application, and each application can only have one Global.asa file." On http://msdn.microsof...v=vs.90%29.aspx there appears this statement: "An ASP-based application is made up of all the files in the application's root directory and any subdirectories. An application starts the first time that a user opens one of the Web pages in the application and ends when the server shuts down." On http://www.haneng.com/lessons_19.asp the author states "Can you have multiple Global.asas? Yes you can, but only one in each directory." He also says "The first problem is that the Application_OnEnd script doesn't run. At least nobody that I have talked two have managed to get it to work." So, the multiple questions: 1. Where the .asp pages comprising something such as a shopping cart system are placed in a sub-directory of the main web site does the entire web site or just the sub-directory constitute "the ASP application" or "Application Root"? 2. Should the cart supplier's global.asa file be in the root directory of the web site or in the 'cart application root directory' which is a sub-directory of the complete web site? 3. What happens of the cart system global.asa file sits in the shop directory and the existing one remains in the site root directory? 4. If only one global.asa file should exist for the whole web site including the shop (it's easy enough to merge the two sets of information), should it be in the site root or the shop directory? 5. If in the shop directory, how do I ensure that the login process (which runs in the web site root) picks up the session security initial setting from a global.asa file residing in a sub-directory? 6. The main part of the web site consists of .html files. Do these pay any regard to the global.asa file as a visitor to the site will only encounter the shop files by using the menu structure of the web site (unless they have bookmarked the shop page)? 7. Several definitions mention the web-server shutting down. Does this literally mean shutting down (power switched off) or just that the last user has exited and the shop files and database files on the web server are not now being accessed by anyone? 8. Does 'application_'onEnd' work assuming some correct code has been entered in the sub-routine? 9. What happens if a user has cookies disabled on their browser? Sorry it's a long one, but I could do with some plain and simple explanations. Thanks.

Link to post
Share on other sites
  • 4 months later...

Yikes: Technically speaking there should only be 1 global.asa file for a website. Actually however, you can have "nested virtual roots" (refer to: http://support.microsoft.com/kb/173307 for info) that contain their own global.asa files but that can really complicate the entire issue. So, in theory, yes, you can have multiple global.asa files but I would stay away from any site structure like that because of the issues it poses. Question 1) It depends on how you've set up your site (and also how you've defined it in IIS assuming you have admin ability to access the IIS server) but generally your application should be defined as starting from the root folder for that site. Question 2) Unless you know how to set up nested virtual roots then yes, I would put the cart vendor's global.asa file in the site's root and us it from there and factor in your own code you require for the global.asa. Question 3) There's no assurance the global.asa file in the shop directory will be read. Question 4) A single global.asa file should always be placed into the root folder of the site (according to Microsoft). Question 5) You can't, because you can't ensure that the global.asa file in any sub-directory will be run. Question 6) As far as I know, as long as a visitor hits the site either to an HTML file or an ASP file, the global.asa file, if it exists, would be run with the sessionOnStart. So in theory a bookmarked page that is to an HTML file should not matter, i.e. it would trigger the sessionOnStart. Question 7) Guess you're referring to the ApplicationOnEnd event: My own experience with this has been that as long as the server is stopped then restarted. But there can be issues where that might not work requiring a true reboot of the machine. Question 8) Yes, applicationOnEnd does work but I have experienced inconsistencies with it. Question 9) Assuming your cart app does not require a database to store session information, probably your cart application might not work.

Edited by ASPete
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...