system — 2012-03-07T07:40:06-05:00 — #1
what is GLOBAL.ASAX File in .NET ?
Main function of GLOBAL.ASAX.?
Advantages and disadvantages of GLOBAL.ASAX?
mittineague — 2012-03-07T19:14:57-05:00 — #2
Hi bulkemailkaps, welcome to the forums,
Please post a sample from the file you're wondering about. Is this file referenced to in any of your other files?
wwb_99 — 2012-03-07T20:35:20-05:00 — #3
@Mitteneague -- it is a structural file, not something one references.
You might want to look at MSDN for such basic questions -- like describing the global.asax file. There aren't any advantages and disadvantages -- it just is and you need to deal with it.
bzforum — 2012-03-14T12:17:41-04:00 — #4
Global.ASAX is an optional file which is used to control Application Level or Session Level Events on your website...it is also popularly known as ASP.NET Application File..In asp it was the Global.asa :)...
There are few techniques which you can use in this File...a very popular one is URL Redirection..you can make more friendly urls using it...so yes...it is how you deal with the file..
dmn_webmaster — 2012-03-14T23:11:11-04:00 — #5
Just gonna add my 2 cents worth.....
Every day every web sever restarts at midnight, or it should. MS servers use a file call global.asa or global.asax to give you control of the server at the application level. In short all websites designed with asp/aspx code in general are called applications.
As someone else has stated you do not need or have to have this file, but if you use it you can do a lot of things otherwise which you couldn't...
In the global.asa/glogal.asax file you have a lot of granular control over your website..... there are 4 main parts to this file
application onstart is executed every day when the server restarts or when you edit and modify this file. This lets you setup any variables you need to make the website work correctly. It also lets you create things like hit counters, database connections and url redirections as someone else in the forum mentioned....
application_onend is executed at the end of the day just before the server actually restarts. Again here you can tidy up behind yourself. Clean up things and so forth.
session_onstart is executed every time a visitor first comes to your website. Here you can setup special code that must run every time a visitor comes to your site. You could create session variables with default values to detect if this is the visitors first visit to a particular page and things like that. You could access application variables and manipulate those as well.
Session_onend is executed every time a visitor session is over. Here you run code to clean up behind each visitor. access database to track time on site and things of that nature.
A simple concurrent visitor counter can be created like this ....
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
application("current_total_visitors") = 0
application("current_total_visitors") = application("current_total_visitors") + 1
application("current_total_visitors") = application("current_total_visitors") - 1
This is just a very basic example...
mittineague — 2014-09-17T23:26:55-04:00 — #6
This topic is now archived. It is frozen and cannot be changed in any way.