You must Sign In to post a response.
  • Category: ASP.NET

    Global.asax

    Hi friends

    how to use Global.asax file in Project. i want to declare one session variable in Project start time and remove that session value if user close the browser. any one tell with example coding?
  • #581268
    in Session_Start event of global.asax file add the following code.

    void Session_Start(Object sender , EventArgs e)
    {
    Session.Add("varName", varValue);
    }

  • #581273
    ok gobinda how to remove when user close browser (click X)
    Regards
    N.Ravindran
    Your Hard work never fails

  • #581294
    It is very hard to track the Browser close int he global,asax file as when the browser is closed the session is automatically terminated and you can not have the access to the event of global.asax file, so it is advisable to make use of some JavaScript code to keep track of the closing window..
    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #581308
    yes pandey i try it in global.asax not call that code for remove session..

    this is explanation of my question pandey..

    i need to avoid multiple login for same user (ASP.Net)...if user sign in i change flag in sql table 'Y' if user click log out i update status in SQL table 'N'

    suppose user close the browser how can i update 'N' in SQL table using javascript or you know any alternate way? please give any idea i will try....

    Regards
    N.Ravindran
    Your Hard work never fails

  • #581436
    Hi please follow the given tips:

    # The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level and session-level events raised by ASP.NET or by HTTP modules.

    # The Global.asax file resides in the root directory of an ASP.NET application.

    # At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplication base class.

    # ASP.NET is configured so that any direct URL request for the Global.asax file is automatically rejected; external users cannot download or view the code in it.

    Regards
    Pankaj Rajput


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.