SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Mar 2012
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what is GLOBAL.ASAX File in .NET

    what is GLOBAL.ASAX File in .NET ?

    Main function of GLOBAL.ASAX.?

    Advantages and disadvantages of GLOBAL.ASAX?

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,182
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    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?

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,633
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    @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.

  4. #4
    SitePoint Enthusiast bzforum's Avatar
    Join Date
    Mar 2012
    Location
    India
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bulkemailkaps View Post
    what is GLOBAL.ASAX File in .NET ?

    Main function of GLOBAL.ASAX.?

    Advantages and disadvantages of GLOBAL.ASAX?
    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..

  5. #5
    SitePoint Member
    Join Date
    Mar 2012
    Location
    North Carolina, USA
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bulkemailkaps View Post
    what is GLOBAL.ASAX File in .NET ?

    Main function of GLOBAL.ASAX.?

    Advantages and disadvantages of GLOBAL.ASAX?
    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
    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

    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
    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

    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>

    Sub Application_onstart
    application("current_total_visitors") = 0
    Sub End

    sub Session_onstart
    Application Lock
    application("current_total_visitors") = application("current_total_visitors") + 1
    application Unlock
    sub end

    Sub Session_onend
    Application Lock
    application("current_total_visitors") = application("current_total_visitors") - 1
    application Unlock
    Sub end

    This is just a very basic example...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •