ASP. NET Online number limit

Source: Internet
Author: User

1, the site initiates the initialization of the online number of variables
application["websitecount"0;
2. New sessions come in

This method executes only when a new session comes in. Can filter out some of the unnecessary, restricted pages, such as the background management system of the page, in the background when the user does not participate in restricting the number of people, so that even after entering the background to access other pages will not trigger the Session_Start method.

Session.Abandon (); indicates that deleting the current session object will trigger the Session_End method.
protected voidsession_start (Object sender, EventArgs e) {application.lock (); application["Websitecount"] = (int) application["Websitecount"] +1;            Application.UnLock (); if(! Request.RawUrl.Equals ("/login.aspx", StringComparison.OrdinalIgnoreCase) &&application["Websitecount"] !=NULL&& Convert.ToInt32 (application["Websitecount"]) >count)                {Session.Abandon (); Response.Redirect ("503.html"); }        }
3, session end, service end session expired
protected void Session_End (Object sender, EventArgs e)        {            application.lock ();            application["websitecount"] = (int) application["  Websitecount"1;            Application.UnLock ();        }

ASP. NET Online number limit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.